MCPcopy
hub / github.com/tinygrad/tinygrad / _encode_decode

Method _encode_decode

tinygrad/runtime/ops_nv.py:347–358  ·  view source on GitHub ↗
(self, bufout:HCQBuffer, bufin:HCQBuffer, desc_buf:HCQBuffer, hist:list[HCQBuffer], shape:tuple[int,...], frame_pos:int)

Source from the content-addressed store, hash-verified

345 def _map(self, buf:HCQBuffer): return self.dev.iface.map(buf._base if buf._base is not None else buf)
346
347 def _encode_decode(self, bufout:HCQBuffer, bufin:HCQBuffer, desc_buf:HCQBuffer, hist:list[HCQBuffer], shape:tuple[int,...], frame_pos:int):
348 assert all(h.va_addr % 0x100 == 0 for h in hist + [bufin, bufout, desc_buf]), "all buffers must be 0x100 aligned"
349
350 h, w = ((2 * shape[0]) // 3 if shape[0] % 3 == 0 else (2 * shape[0] - 1) // 3), shape[1]
351 self.dev._ensure_has_vid_hw(w, h)
352
353 q = NVVideoQueue().wait(self.dev.timeline_signal, self.dev.timeline_value - 1)
354 with hcq_profile(self.dev, queue=q, desc="HEVC Decode", enabled=PROFILE, dev_suff="NVDEC"):
355 q.decode_hevc_chunk(desc_buf, bufin, bufout, frame_pos, hist, [(frame_pos-x) % (len(hist) + 1) for x in range(len(hist), 0, -1)],
356 round_up(w, 64)*round_up(h, 64), self.dev.vid_coloc_buf, self.dev.vid_filter_buf, self.dev.intra_top_off,
357 self.dev.intra_unk_off, self.dev.vid_stat_buf)
358 q.signal(self.dev.timeline_signal, self.dev.next_timeline()).submit(self.dev)
359
360@dataclass
361class GPFifo:

Callers 1

exec_encdecFunction · 0.45

Calls 9

hcq_profileFunction · 0.90
round_upFunction · 0.90
NVVideoQueueClass · 0.85
_ensure_has_vid_hwMethod · 0.80
decode_hevc_chunkMethod · 0.80
submitMethod · 0.80
next_timelineMethod · 0.80
waitMethod · 0.45
signalMethod · 0.45

Tested by

no test coverage detected