private initMemoryUsageFromPrecomputed()

in frontend/app/components/memory_viewer/memory_usage/memory_usage.ts [109:140]


  private initMemoryUsageFromPrecomputed(
      preprocess: preprocessedProto.PreprocessResult) {
    // Copy the fields from preprocessed result.
    this.moduleName = preprocess.moduleName || '';
    this.peakHeapSizeBytes = (preprocess.peakHeapMib || 0) * 1024 * 1024;
    this.unpaddedPeakHeapSizeBytes =
        (preprocess.peakUnpaddedHeapMib || 0) * 1024 * 1024;
    this.peakHeapSizePosition = (preprocess.peakHeapSizePosition || 0);
    this.heapSizes = preprocess.heapSizes || [];
    this.unpaddedHeapSizes = preprocess.unpaddedHeapSizes || [];
    if (preprocess.logicalBufferSpans) {
      for (const [key, value] of Object.entries(
               preprocess.logicalBufferSpans)) {
        this.logicalBufferSpans[utils.toNumber(key)] =
            [value.start || 0, value.limit || 0];
      }
    }
    for (const heapObject of preprocess.maxHeap || []) {
      this.maxHeap.push({
        instructionName: heapObject.instructionName,
        shape: heapObject.shapeString,
        tfOpName: heapObject.tfOpName,
        sizeMiB: heapObject.logicalBufferSizeMib,
        unpaddedSizeMiB: heapObject.unpaddedShapeMib,
        color: this.nColor++,
        groupName: heapObject.groupName,
        opcode: heapObject.opCode,
        logicalBufferId: heapObject.logicalBufferId,
      });
    }
    this.createMaxHeapIndex();
  }