(dataId: DataId, customTexShape?: [number, number])
| 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, |
no test coverage detected