MCPcopy
hub / github.com/tensorflow/tfjs / decode

Method decode

tfjs-backend-webgl/src/backend_webgl.ts:843–872  ·  view source on GitHub ↗
(dataId: DataId, customTexShape?: [number, number])

Source from the content-addressed store, hash-verified

841 }
842
843 private decode(dataId: DataId, customTexShape?: [number, number]):
844 TensorInfo {
845 const texData = this.texData.get(dataId);
846 const {isPacked, shape, dtype} = texData;
847 if (customTexShape != null) {
848 const size = util.sizeFromShape(shape);
849 const texSize = customTexShape[0] * customTexShape[1] * 4;
850 util.assert(
851 size <= texSize,
852 () => 'customTexShape is too small. ' +
853 'Row * Column * 4 should be equal or larger than the ' +
854 'size of the tensor data.');
855 }
856 const shapeAs3D =
857 webgl_util.getShapeAs3D(shape) as [number, number, number];
858 let program;
859 if (isPacked) {
860 program = new DecodeMatrixPackedProgram(shapeAs3D);
861 } else {
862 program = new DecodeMatrixProgram(shapeAs3D);
863 }
864 const preventEagerUnpackingOfOutput = true;
865 const customValues =
866 [customTexShape != null ? customTexShape :
867 tex_util.getDenseTexShape(shapeAs3D)];
868 const out = this.runWebGLProgram(
869 program, [{shape: shapeAs3D, dtype, dataId}], dtype, customValues,
870 preventEagerUnpackingOfOutput, customTexShape);
871 return {dtype, shape, dataId: out.dataId};
872 }
873
874 runWebGLProgram(
875 program: GPGPUProgram, inputs: TensorInfo[], outputDtype: DataType,

Callers 3

readMethod · 0.95
readToGPUMethod · 0.95
getValuesFromTextureMethod · 0.95

Calls 2

runWebGLProgramMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected