o
    ^iGi                     @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ ejejeZejed	gZd
d Ze  dd ZG dd deZdd ZddddddZddddddZdZ dd Z!dd Z"G dd  d eZ#G d!d" d"eZ$dS )#    N)Path)knobs)	GPUTarget)	GPUDriver)_allocation)compile_module_from_src)TensorDescriptorincludec                    s   dd l }| dkrd S dd lddlm}m}m}mm m} G  fdddj	}
|||||||}zdj}W n
 tyL   Y d S w | g|_||_dd }	fd	d
}
|||
|	rut|	S d S )Nr   Linux)c_charc_intc_size_tc_void_pc_char_pPOINTERc                       s   e Zd Zdfd fgZdS )z8_find_already_mmapped_dylib_on_linux.<locals>.DlPhdrInfo	dlpi_addr	dlpi_nameN)__name__
__module____qualname___fields_ )r   r   r   U/var/www/html/RAG/RAG_venv/lib/python3.10/site-packages/triton/backends/amd/driver.py
DlPhdrInfo   s    r   z	libc.so.6i      c                    s@   | j j}tt|}|jv r ||tt| dS dS )Nr   r   )	contentsr   r   osfsdecodenamememmoveminlen)infosizedatar   p)ctypeslib_namemax_path_lengthr   r   callback3   s   
z6_find_already_mmapped_dylib_on_linux.<locals>.callback)platformsystemr&   r   r   r   r   r   r   	Structure	CFUNCTYPECDLLdl_iterate_phdr	Exceptionargtypesrestypecreate_string_bufferr   r   	string_at)r'   r*   r   r   r   r   r   
callback_tr/   pathr)   r   )r   r   r&   r'   r(   r   $_find_already_mmapped_dylib_on_linux   s(    
	r7   c               	      s  d t jj } r|  rtj| r| S td|  d  t }|r7tj|r-|S td| d  g }tj	tj
td }tj|rM|S || dd l}| }| }|jrf|g| }|D ]}tj	|dd }tj|r}|  S || qhtd	}|r|d
D ]}	tj	|	 }
tj|
r|
  S ||
 qtd}|rtj	|d }tj|r|S || z%tddg  }|rtj	|d }tj|r|W S || W n tjtfy   Y nw td}|rtj	|d }tj|r|S || tddgjdd} fdd| D }|D ]}tj|r9|  S || q,tj	d }tj|rP|S || td  d| )Nzlibamdhip64.sozTRITON_LIBHIP_PATH 'z' does not point to a valid zmemory mapped 'z'' in process does not point to a valid libr   torchLD_LIBRARY_PATH:HIP_PATH	hipconfigz--path	ROCM_PATHz/sbin/ldconfigz-pignore)errorsc                    s&   g | ]}|   r| d  qS ))stripendswithsplit).0liner'   r   r   
<listcomp>   s   & z2_get_path_to_hip_runtime_dylib.<locals>.<listcomp>z/opt/rocm/lib/zcannot locate z after attempted paths )r   amdlibhip_pathrC   r   r6   existsRuntimeErrorr7   joindirname__file__appendsitegetsitepackagesgetusersitepackagesENABLE_USER_SITEgetenvrD   
subprocesscheck_outputdecoderB   CalledProcessErrorFileNotFoundError
splitlines)env_libhip_pathmmapped_pathpaths	local_librQ   site_packages	user_siter6   env_ld_library_pathdfenv_hip_pathhip_lib_pathhip_rootenv_rocm_pathrocm_lib_pathlibslocsloccommon_install_pathr   rG   r   _get_path_to_hip_runtime_dylibA   s   








rn   c                       s$   e Zd Z fddZdd Z  ZS )HIPUtilsc                    s"   t | dstt| | | _| jS )Ninstance)hasattrsuperro   __new__rp   )cls	__class__r   r   rs      s   
zHIPUtils.__new__c                 C   sL   t  }ttjtd }|d|d}t|dt	d}|j
| _
|j| _d S )Nzdriver.cz/*py_libhip_search_path*/r   	hip_utilssrcr   include_dirs)rn   r   r   r6   rM   rN   	read_textreplacer   rz   load_binaryget_device_properties)selfrJ   ry   modr   r   r   __init__   s   zHIPUtils.__init__)r   r   r   rs   r   __classcell__r   r   ru   r   ro      s    ro   c                 C   s8   | d dkrdS dddddddd	d
ddddddd|  S )Nr   *hipDeviceptr_tint8_tint16_tint32_tint64_tuint8_tuint16_tuint32_tuint64_tdouble)i1i8i16i32i64u1u8u16u32u64fp16bf16fp32f32fp64r   )tyr   r   r   	ty_to_cpp   s(   r   r   r   r   )r   r   r   r   r   	pack_fp16	pack_bf16	pack_fp32	pack_fp64piiiKKOOOOOc                    s  dd }fdd fdd fddd	d
 t || D }dfdd| D }t| }dt| }ttt|d}dd
 t |D }t	|dkrfdddd |
 D  nd}g }|
 D ]&\}}	|	dkrwqn|	tv r|t|	  d|  qn|t|	 d|  qnd|}
g }|
 D ].\}}	|	d dkr|d| d q|	tv r|d| d q|	dkr|d|  qdd |
 D }t }ttt	|}dd |
 D }|d |d d| d t	|
dkrd|
 nd d!d| d"| d#| d$d% fd&d|
 D  d'| d(| d)d%| d*d+d,d |
 D  d-t	|dkrJdd| nd d.}|S )/Nc                 S   s   g }| D ]S}t |trR|drR|dd }td| }|d|  td| D ]}|d q,|d t|D ]}|d	 q=t|D ]}|d qIq|| q|S )
N
tensordesc,r   ztensordesc<([^[>]*)r      r   r   r   )	
isinstancestr
startswithcountrematchgrouprP   range)	signatureoutputsigndimdtype_r   r   r   _expand_signature   s    
z(make_launcher.<locals>._expand_signaturec                    s   t | trdt | S | S )Nr   )r   tuplerM   map)r   )_serialize_signaturer   r   r      s   
z+make_launcher.<locals>._serialize_signaturec                    sJ   t | trdt | }d| dS | d dkrdS | dkr!dS t| S )Nr   []r   r   z	PyObject*	constexprr   r   rM   r   r   r   val_extracted_typer   r   r      s   
z&make_launcher.<locals>._extracted_typec                    sd   t | trdt | }d| dS | d dkrdS | dkr!dS dd	d
dddddddd
t|  S )N ()r   r   Or   rc   lbhiLBHIK)
r   longr   r   r   r   r   r   r   r   r   r   	format_ofr   r   r   	  s(   
z make_launcher.<locals>.format_ofc                 S      i | ]\}}||qS r   r   )rE   idxsr   r   r   
<dictcomp>      z!make_launcher.<locals>.<dictcomp>r   c                    s   g | ]} |qS r   r   )rE   r   r   r   r   rH      s    z!make_launcher.<locals>.<listcomp>r   c                 S   r   r   r   )rE   r   r   r   r   r   r   $  r   r   , c                 s   s    | ]
\}}d | V  qdS )z&_argNr   rE   r   r   r   r   r   	<genexpr>%  s    z make_launcher.<locals>.<genexpr>r   z argr   ptr_infoz.dev_ptr_arg_storagec              
   S   s<   g | ]\}}|t v rt |  d | dt|  d| dqS ) _argz_storage = z(_argz);)FLOAT_STORAGE_TYPEFLOAT_PACK_FUNCTIONr   r   r   r   rH   :  s
    "c                 S   s"   g | ]\}}|d krd| qS )r   z&argr   r   r   r   r   rH   D  s   " z&global_scratchz&profile_scratcha\  
#define __HIP_PLATFORM_AMD__
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#include <Python.h>
#include <dlfcn.h>
#include <stdbool.h>
#include <dlfcn.h>

// The list of paths to search for the HIP runtime library. The caller Python
// code should substitute the search path placeholder.
static const char *hipLibSearchPaths[] = {"a  "};

// The list of HIP dynamic library symbols and their signature we are interested
// in this file.
#define HIP_SYMBOL_LIST(FOR_EACH_ERR_FN, FOR_EACH_STR_FN)                     \
  FOR_EACH_STR_FN(hipGetLastError)                                            \
  FOR_EACH_STR_FN(hipGetErrorString, hipError_t hipError)                     \
  FOR_EACH_ERR_FN(hipModuleLaunchKernel, hipFunction_t f,                     \
                  unsigned int gridDimX, unsigned int gridDimY,               \
                  unsigned int gridDimZ, unsigned int blockDimX,              \
                  unsigned int blockDimY, unsigned int blockDimZ,             \
                  unsigned int sharedMemBytes, hipStream_t stream,            \
                  void **kernelParams, void **extra)                          \
  FOR_EACH_ERR_FN(hipModuleLaunchCooperativeKernel, hipFunction_t f,          \
                  unsigned int gridDimX, unsigned int gridDimY,               \
                  unsigned int gridDimZ, unsigned int blockDimX,              \
                  unsigned int blockDimY, unsigned int blockDimZ,             \
                  unsigned int sharedMemBytes, hipStream_t stream,            \
                  void **kernelParams, void **extra)                          \
  FOR_EACH_ERR_FN(hipPointerGetAttribute, void *data,                         \
                  hipPointer_attribute attribute, hipDeviceptr_t ptr)

// The HIP symbol table for holding resolved dynamic library symbols.
struct HIPSymbolTable {
#define DEFINE_EACH_ERR_FIELD(hipSymbolName, ...)                             \
  hipError_t (*hipSymbolName)(__VA_ARGS__);
#define DEFINE_EACH_STR_FIELD(hipSymbolName, ...)                             \
  const char *(*hipSymbolName)(__VA_ARGS__);

  HIP_SYMBOL_LIST(DEFINE_EACH_ERR_FIELD, DEFINE_EACH_STR_FIELD)
};

static struct HIPSymbolTable hipSymbolTable;

bool initSymbolTable() {
  // Use the HIP runtime library loaded into the existing process if it exits.
  void *lib = dlopen("libamdhip64.so", RTLD_NOLOAD);

  // Otherwise, go through the list of search paths to dlopen the first HIP
  // driver library.
  if (!lib) {
    int n = sizeof(hipLibSearchPaths) / sizeof(hipLibSearchPaths[0]);
    for (int i = 0; i < n; ++i) {
      void *handle = dlopen(hipLibSearchPaths[i], RTLD_LAZY | RTLD_LOCAL);
      if (handle) {
        lib = handle;
      }
    }
  }
  if (!lib) {
    PyErr_SetString(PyExc_RuntimeError, "cannot open libamdhip64.so");
    return false;
  }

  typedef hipError_t (*hipGetProcAddress_fn)(
      const char *symbol, void **pfn, int hipVersion, uint64_t hipFlags,
      hipDriverProcAddressQueryResult *symbolStatus);
  hipGetProcAddress_fn hipGetProcAddress;
  dlerror(); // Clear existing errors
  const char *error = NULL;
  *(void **)&hipGetProcAddress = dlsym(lib, "hipGetProcAddress");
  error = dlerror();
  if (error) {
    PyErr_SetString(PyExc_RuntimeError,
                    "cannot query 'hipGetProcAddress' from libamdhip64.so");
    dlclose(lib);
    return false;
  }

  // Resolve all symbols we are interested in.
  int hipVersion = HIP_VERSION;
  uint64_t hipFlags = 0;
  hipDriverProcAddressQueryResult symbolStatus;
  hipError_t status = hipSuccess;
#define QUERY_EACH_FN(hipSymbolName, ...)                                        status = hipGetProcAddress(#hipSymbolName,                                                                (void **)&hipSymbolTable.hipSymbolName,                                        hipVersion, hipFlags, &symbolStatus);               if (status != hipSuccess) {                                                     PyErr_SetString(PyExc_RuntimeError,                                                            "cannot get address for '" #hipSymbolName                                      "' from libamdhip64.so");                                      dlclose(lib);                                                                  return false;                                                                }

  HIP_SYMBOL_LIST(QUERY_EACH_FN, QUERY_EACH_FN)

  return true;
}

static inline void gpuAssert(hipError_t code, const char *file, int line)
{
   if (code != HIP_SUCCESS)
   {
      const char* prefix = "Triton Error [HIP]: ";
       const char* str = hipSymbolTable.hipGetErrorString(code);
      char err[1024] = {0};
      snprintf(err, 1024, "%s Code: %d, Messsage: %s", prefix, code, str );
      PyErr_SetString(PyExc_RuntimeError, err);
   }
}

#define HIP_CHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); }

static void _launch(int gridX, int gridY, int gridZ, int num_warps, int num_ctas, int launch_cooperative_grid, int clusterDimX, int clusterDimY, int clusterDimZ, int shared_memory, hipStream_t stream, hipFunction_t function, hipDeviceptr_t profile_scratchz>) {
  hipDeviceptr_t global_scratch = 0;
  void *params[] = { z };
  if (gridX*gridY*gridZ > 0 && launch_cooperative_grid) {
    HIP_CHECK(hipSymbolTable.hipModuleLaunchCooperativeKernel(function, gridX, gridY, gridZ, z*num_warps, 1, 1, shared_memory, stream, params, 0));
    return;
  }
  if (gridX*gridY*gridZ > 0) {
    HIP_CHECK(hipSymbolTable.hipModuleLaunchKernel(function, gridX, gridY, gridZ, ae
  *num_warps, 1, 1, shared_memory, stream, params, 0));
  }
}

typedef struct _DevicePtrInfo {
    hipDeviceptr_t dev_ptr;
    bool valid;
} DevicePtrInfo;

static PyObject* data_ptr_str = NULL;

static inline DevicePtrInfo getPointer(PyObject *obj, int idx) {
  DevicePtrInfo ptr_info;
  hipError_t status = hipSuccess;
  ptr_info.dev_ptr = 0;
  ptr_info.valid = true;
  if (PyLong_Check(obj)) {
    ptr_info.dev_ptr = (hipDeviceptr_t)PyLong_AsUnsignedLongLong(obj);
    return ptr_info;
  }
  if (obj == Py_None) {
    // valid nullptr
    return ptr_info;
  }
  PyObject *ret = PyObject_CallMethodNoArgs(obj, data_ptr_str);
  if (!ret) {
    PyErr_SetString(PyExc_TypeError, "Pointer argument must be either uint64 or have data_ptr method");
    ptr_info.valid = false;
    goto cleanup;
  }
  if (!PyLong_Check(ret)) {
    PyErr_SetString(PyExc_TypeError, "data_ptr method of Pointer object must return 64-bit int");
    ptr_info.valid = false;
    goto cleanup;
  }
  ptr_info.dev_ptr = (hipDeviceptr_t)PyLong_AsUnsignedLongLong(ret);
  if (!ptr_info.dev_ptr)
    goto cleanup;
  uint64_t dev_ptr;
  status = hipSymbolTable.hipPointerGetAttribute(&dev_ptr, HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, ptr_info.dev_ptr);
  if (status == hipErrorInvalidValue) {
      PyErr_Format(PyExc_ValueError,
                   "Pointer argument (at %d) cannot be accessed from Triton (cpu tensor?)", idx);
      ptr_info.valid = false;
      // Clear and ignore HIP error
      (void)hipSymbolTable.hipGetLastError();
  }
  ptr_info.dev_ptr = (hipDeviceptr_t)dev_ptr;
cleanup:
  Py_DECREF(ret);
  return ptr_info;
}

static uint16_t pack_fp16(double f) {
    uint16_t result;
    // from https://github.com/python/pythoncapi-compat/blob/5e317108f872c904eb726cb8d560dcadbdf88a72/pythoncapi_compat.h#L482-L492
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
    _PyFloat_Pack2(f, (unsigned char*)&result, 1);
#else
    PyFloat_Pack2(f, (char*)&result, 1);
#endif
    return result;
}

static uint16_t pack_bf16(double f) {
    float f32 = (float)f;
    uint32_t u32 = *(uint32_t*)&f32;
    return (uint16_t)(u32 >> 16);
}

static uint32_t pack_fp32(double f) {
    float f32 = (float)f;
    return *(uint32_t*)&f32;
}

static uint64_t pack_fp64(double f) {
    return *(uint64_t*)&f;
}

static PyObject* launch(PyObject* self, PyObject* args) {
  int gridX, gridY, gridZ;
  uint64_t _stream;
  uint64_t _function;
  int launch_cooperative_grid;
  PyObject *profile_scratch_obj = NULL;
  PyObject *launch_enter_hook = NULL;
  PyObject *launch_exit_hook = NULL;
  PyObject *kernel_metadata = NULL;
  PyObject *launch_metadata = NULL;
   c                    s$   g | ]\}} | d | dqS )r   ; r   r   r   r   r   rH     s   $ z
  if(!PyArg_ParseTuple(args, "a,  ", &launch_cooperative_grid,
                                           &gridX, &gridY, &gridZ, &_stream, &_function, &profile_scratch_obj,
                                           &kernel_metadata, &launch_metadata,
                                           &launch_enter_hook, &launch_exit_hook z)) {
    return NULL;
  }

  a  

  // extract kernel metadata
  int num_warps, num_ctas, shared_memory, clusterDimX, clusterDimY, clusterDimZ;
  if (!PyArg_ParseTuple(kernel_metadata, "iiiiii", &num_warps, &num_ctas, &shared_memory, &clusterDimX, &clusterDimY, &clusterDimZ)) {
    return NULL;
  }
  // extract launch metadata
  if (launch_enter_hook != Py_None){
    PyObject* ret = PyObject_CallOneArg(launch_enter_hook, launch_metadata);
    if (!ret)
      return NULL;
    Py_DECREF(ret);
  }

  hipDeviceptr_t profile_scratch = 0;
  if (profile_scratch_obj != Py_None) {
    DevicePtrInfo profile_scratch_info = getPointer(profile_scratch_obj, -1);
    if (!profile_scratch_info.valid) {
      return NULL;
    }
    profile_scratch = profile_scratch_info.dev_ptr;
  }

  // raise exception asap
  r   c                 S   s>   g | ]\}}|d  dkrd| d| d| d| d	ndqS )r   r   zDevicePtrInfo ptr_infoz = getPointer(_argr   z); if (!ptr_infoz.valid) return NULL;r   r   r   r   r   r   rH   =  s   > z;
  _launch(gridX, gridY, gridZ, num_warps, num_ctas, launch_cooperative_grid, clusterDimX, clusterDimY, clusterDimZ, shared_memory, (hipStream_t)_stream, (hipFunction_t)_function, (hipDeviceptr_t)profile_scratcha  );

  if(launch_exit_hook != Py_None){
    PyObject* ret = PyObject_CallOneArg(launch_exit_hook, launch_metadata);
    if (!ret)
      return NULL;
    Py_DECREF(ret);
  }

  if(PyErr_Occurred()) {
    return NULL;
  }
  Py_RETURN_NONE;
}

static PyMethodDef ModuleMethods[] = {
  {"launch", launch, METH_VARARGS, "Entry point for all kernels with this signature"},
  {NULL, NULL, 0, NULL} // sentinel
};

static struct PyModuleDef ModuleDef = {
  PyModuleDef_HEAD_INIT,
  "__triton_launcher",
  NULL, //documentation
  -1, //size
  ModuleMethods
};

PyMODINIT_FUNC PyInit___triton_launcher(void) {
  if (!initSymbolTable()) {
    return NULL;
  }
  PyObject *m = PyModule_Create(&ModuleDef);
  if(m == NULL) {
    return NULL;
  }
  data_ptr_str = PyUnicode_InternFromString("data_ptr");
  if(data_ptr_str == NULL) {
    return NULL;
  }
  PyModule_AddFunctions(m, ModuleMethods);
  return m;
}
)	enumeratevaluesrM   _BASE_ARGS_FORMATr   listfilterboolrD   r!   itemsr   rP   r   rn   r   )	constantsr   	warp_sizer   args_formatformat	args_listarg_decl_listr   r   	arg_declsinternal_args_listfloat_storage_declsrJ   paramsry   r   )r   r   r   r   make_launcher   s   
,


tvx| V  W  Z  ^  w  x   %r   c                    s    fdd}|S )zN
    Replace all tensor descriptors with the base ptr, shape, and strides
    c                     s   | d t t }| t td  }g }|D ]%}t|tr4||jg|j|j|jdk|j|j q|	| q g ||R  S )Nnan)
r!   r   r   r   extendbaseshapestridespaddingrP   )args	meta_argsraw_kernel_args
final_argsarglauncherr   r   innerr  s   
2z,wrap_handle_tensor_descriptor.<locals>.innerr   )r   r   r   r   r   wrap_handle_tensor_descriptorm  s   r  c                   @   s   e Zd Zdd Zdd ZdS )HIPLauncherc                    s   t drjnt }fdd  fdd| D }dd j D }t|||jtdtd}t	d	d
 |
 D }|rFt|jn|j| _|j| _|j| _|j| _d S )Nr   c                    s   t | tr jj| fS | S N)r   r   fn	arg_namesindex)x)ry   r   r   <lambda>  s    z&HIPLauncher.__init__.<locals>.<lambda>c                    s   i | ]	\}} ||qS r   r   rE   r   value)arg_idxr   r   r     s    z(HIPLauncher.__init__.<locals>.<dictcomp>c                 S   r   r   r   r	  r   r   r   r     r   __triton_launcherrx   c                 s   s$    | ]}t |to|d V  qdS )r   N)r   r   r   )rE   r   r   r   r   r     s   " z'HIPLauncher.__init__.<locals>.<genexpr>)rq   r   dictr   r   r   r   r   rz   anyr   r  launchlaunch_cooperative_gridprofile_scratch_sizeprofile_scratch_align)r   ry   metadatar   r   r   has_tensor_desc_argr   )r  ry   r   r     s   zHIPLauncher.__init__c           	         sH    fdd}|| j | jtj}| j| j ||g|R   d S )Nc                    s4   | dkr   }||  }|  }|||S d S Nr   )get)r#   align	allocator	grid_size
alloc_sizealloc_fngridXgridYgridZstreamr   r   allocate_scratch  s   z.HIPLauncher.__call__.<locals>.allocate_scratch)r  r  r   _profile_allocatorr  r  )	r   r  r  r  r   functionr   r!  profile_scratchr   r  r   __call__  s
   
$zHIPLauncher.__call__N)r   r   r   r   r%  r   r   r   r   r    s    r  c                       sj   e Zd Z fddZdd Zedd Zdedefd	d
Zdd Z	dd Z
dd Zdd Zdd Z  ZS )	HIPDriverc                    s   t    t | _t| _d S r  )rr   r   ro   utilsr  launcher_cls)r   ru   r   r   r     s   

zHIPDriver.__init__c                 C   s   dd l }|jS r  )r9   cudar   r9   r   r   r   get_device_interface  s   zHIPDriver.get_device_interfacec                  C   s6   zdd l } | j o| jjd uW S  ty   Y dS w )Nr   F)r9   r)  is_availableversionhipImportError)r9   r   r   r   	is_active  s   zHIPDriver.is_activer   returnc                 C   s   t |S r  )r   )r   r   r   r   r   map_python_to_cpp_type  s   z HIPDriver.map_python_to_cpp_typec                 C   sB   |   }| j|}tjjp|d }|d }td|dd |S )NarchwarpSizer.  r;   r   )get_current_devicer'  r~   r   runtimeoverride_archr   rD   )r   devicedevice_propertiesr3  r   r   r   r   get_current_target  s
   zHIPDriver.get_current_targetc                 C   s   dd l }|d|  S )Nr   r)  )r9   r8  r5  r*  r   r   r   get_active_torch_device  s   z!HIPDriver.get_active_torch_devicec                 C   s   ddl m} |S )Nr   )do_bench)triton.testingr<  )r   r<  r   r   r   get_benchmarker  s   zHIPDriver.get_benchmarkerc                 C   s&   dd l }d}|jt|d |jddS )Nr   i      r)  )r   r8  )r9   emptyint)r   r9   
cache_sizer   r   r   get_empty_cache_for_benchmark  s   z'HIPDriver.get_empty_cache_for_benchmarkc                 C   s   |   d S r  )zero_)r   cacher   r   r   clear_cache  s   zHIPDriver.clear_cache)r   r   r   r   r+  staticmethodr0  r   r2  r:  r;  r>  rC  rF  r   r   r   ru   r   r&    s    
r&  )%	functoolsr   rV   r   pathlibr   tritonr   triton.backends.compilerr   triton.backends.driverr   triton.runtimer   triton.runtime.buildr   triton.tools.tensor_descriptorr   r6   rN   realpathrO   rM   rz   r7   	lru_cachern   objectro   r   r   r   r   r   r  r  r&  r   r   r   r   <module>   sL    0
_    