@@ -66,11 +66,11 @@ def get_metadata(keys:list[Any], contexts:list[list[TrackedGraphRewrite]]) -> li
66
66
67
67
@functools .lru_cache (None )
68
68
def _prg (k :Kernel ): return k .to_program ().src
69
- def get_details (k :Any , ctx :TrackedGraphRewrite , metadata :GraphRewriteMetadata ) -> GraphRewriteDetails :
69
+ def get_details (k :Any , ctx :TrackedGraphRewrite , metadata :GraphRewriteMetadata , offset = 0 , limit = 200 ) -> GraphRewriteDetails :
70
70
ret :GraphRewriteDetails = {"uops" :[pcall (str , sink := ctx .sink )], "graphs" :[uop_to_json (sink )], "code_line" :lines (ctx .loc [0 ])[ctx .loc [1 ]- 1 ].strip (),
71
71
"kernel_code" :pcall (_prg , k ) if isinstance (k , Kernel ) else None , "diffs" :[], "upats" :[], "changed_nodes" :[], ** metadata }
72
72
replaces : dict [UOp , UOp ] = {}
73
- for i ,(u0 ,u1 ,upat ) in enumerate (tqdm (ctx .matches )):
73
+ for i ,(u0 ,u1 ,upat ) in enumerate (tqdm (ctx .matches [ offset : offset + limit ] )):
74
74
replaces [u0 ] = u1
75
75
new_sink = sink .substitute (replaces )
76
76
ret ["graphs" ].append (new_sink_js := uop_to_json (new_sink ))
@@ -127,10 +127,10 @@ def do_GET(self):
127
127
if url .path .endswith (".css" ): content_type = "text/css"
128
128
except FileNotFoundError : status_code = 404
129
129
elif url .path == "/kernels" :
130
- query = parse_qs (url .query )
131
- if ( qkernel := query . get ( "kernel" )) is not None :
132
- kidx , ridx = int ( qkernel [ 0 ] ), int ( query [ "idx" ][ 0 ] )
133
- jret :Any = get_details (contexts [0 ][kidx ], contexts [1 ][kidx ][ridx ], kernels [int ( qkernel [ 0 ])] [1 ][int ( query [ "idx" ][ 0 ])] )
130
+ if "kernel" in ( query := parse_qs (url .query )):
131
+ def getarg ( k : str , default = 0 ): return int ( query [ k ][ 0 ]) if k in query else default
132
+ kidx , ridx = getarg ( "kernel" ), getarg ( "idx" )
133
+ jret :Any = get_details (contexts [0 ][kidx ], contexts [1 ][kidx ][ridx ], kernels [kidx ] [1 ][ridx ], getarg ( "offset" , 0 ), getarg ( "limit" , 200 ) )
134
134
else : jret = kernels
135
135
ret , content_type = json .dumps (jret ).encode (), "application/json"
136
136
elif url .path == "/get_profile" and perfetto_profile is not None : ret , content_type = perfetto_profile , "application/json"
0 commit comments