MCPcopy Create free account
hub / github.com/apache/tvm / showImage

Method showImage

web/src/runtime.ts:1621–1638  ·  view source on GitHub ↗

* Show image in canvas. * * @param dataRGBA Image array in height x width uint32 Tensor RGBA format on GPU.

(dataRGBA: Tensor)

Source from the content-addressed store, hash-verified

1619 * @param dataRGBA Image array in height x width uint32 Tensor RGBA format on GPU.
1620 */
1621 showImage(dataRGBA: Tensor) {
1622 if (dataRGBA.shape.length != 2) {
1623 throw Error("Require a height x width uint32 Tensor in RGBA" +
1624 "get shape=" + dataRGBA.shape.toString() + " instead."
1625 );
1626 }
1627 if (dataRGBA.device.deviceType != DeviceStrToEnum.webgpu) {
1628 throw new Error("Can only run showImage on WebGPU array, " +
1629 "get " + DeviceEnumToStr[dataRGBA.device.deviceType] + " instead.");
1630 }
1631 if (dataRGBA.dtype != "uint32") {
1632 throw Error("Require a height x width uint32 Tensor in RGBA, " +
1633 "get " + dataRGBA.dtype + " instead.");
1634 }
1635 this.lib.webGPUContext?.drawImageFromBuffer(
1636 dataRGBA.getDataPtr(), dataRGBA.shape[0], dataRGBA.shape[1]
1637 );
1638 }
1639
1640 /**
1641 * Clear canvas

Callers

nothing calls this directly

Calls 3

drawImageFromBufferMethod · 0.80
getDataPtrMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected