MCPcopy Index your code
hub / github.com/apache/tvm / deviceAllocDataSpace

Method deviceAllocDataSpace

web/src/webgpu.ts:906–922  ·  view source on GitHub ↗
(nbytes: number)

Source from the content-addressed store, hash-verified

904
905 // DeviceAPI
906 private deviceAllocDataSpace(nbytes: number): GPUPointer {
907 // allocate 0 bytes buffer as 1 bytes buffer.
908 if (nbytes == 0) {
909 nbytes = 1;
910 }
911 const buffer = tryCreateBuffer(this.device, {
912 size: nbytes,
913 usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
914 });
915 this.currAllocatedBytes += nbytes;
916 this.allAllocatedBytes += nbytes;
917 if (this.currAllocatedBytes > this.peakAllocatedBytes) {
918 this.peakAllocatedBytes = this.currAllocatedBytes;
919 }
920 const ptr = this.attachToBufferTable(buffer);
921 return ptr;
922 }
923
924 private deviceFreeDataSpace(ptr: GPUPointer): void {
925 const idx = ptr;

Callers 1

getDeviceAPIMethod · 0.95

Calls 2

attachToBufferTableMethod · 0.95
tryCreateBufferFunction · 0.85

Tested by

no test coverage detected