@tensorflow/tfjs-backend-webgl
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -20,6 +20,3 @@ /** | ||
this.variableNames = ['A']; | ||
const windowSize = reduceInfo.windowSize; | ||
const batchSize = reduceInfo.batchSize; | ||
const inSize = reduceInfo.inSize; | ||
const outSize = Math.ceil(inSize / windowSize); | ||
const { windowSize, batchSize, outSize } = reduceInfo; | ||
if (!firstPass) { | ||
@@ -26,0 +23,0 @@ this.variableNames.push('bestIndicesA'); |
@@ -19,13 +19,31 @@ /** | ||
import { ReduceProgram } from '../reduce_gpu'; | ||
// Returns an array of configuration objects that describe each stage of the | ||
// reduction. | ||
function getReductionStages(inShape) { | ||
const stages = []; | ||
while (stages.length === 0 || stages[stages.length - 1].outSize !== 1) { | ||
const outSize = stages.length ? stages[stages.length - 1].outSize : inShape[1]; | ||
const windowSize = backend_util.computeOptimalWindowSize(outSize); | ||
stages.push({ | ||
inSize: outSize, | ||
windowSize, | ||
outSize: Math.ceil(outSize / windowSize) | ||
}); | ||
} | ||
return stages; | ||
} | ||
export function reduce(x, dtype, reductionType, backend) { | ||
const [batchSize, inSize] = x.shape; | ||
const windowSize = backend_util.computeOptimalWindowSize(inSize); | ||
const reduceInfo = { windowSize, inSize, batchSize }; | ||
const program = new ReduceProgram(reduceInfo, reductionType); | ||
const output = backend.runWebGLProgram(program, [x], dtype); | ||
if (output.shape[1] === 1) { | ||
return output; | ||
const reductionStages = getReductionStages(x.shape); | ||
let result = x; | ||
for (let i = 0; i < reductionStages.length; i++) { | ||
const { inSize, windowSize, outSize } = reductionStages[i]; | ||
const program = new ReduceProgram({ windowSize, inSize, batchSize: x.shape[0], outSize }, reductionType); | ||
const previousResult = result; | ||
result = backend.runWebGLProgram(program, [result], dtype); | ||
if (previousResult.dataId !== x.dataId) { | ||
backend.disposeData(previousResult.dataId); | ||
} | ||
} | ||
return reduce(output, dtype, reductionType, backend); | ||
return result; | ||
} | ||
//# sourceMappingURL=reduce.js.map |
@@ -20,6 +20,3 @@ /** | ||
this.variableNames = ['x']; | ||
const windowSize = reduceInfo.windowSize; | ||
const batchSize = reduceInfo.batchSize; | ||
const inSize = reduceInfo.inSize; | ||
const outSize = Math.ceil(inSize / windowSize); | ||
const { windowSize, batchSize, inSize, outSize } = reduceInfo; | ||
this.outputShape = [batchSize, outSize]; | ||
@@ -26,0 +23,0 @@ let initializationValue = '0.0'; |
/** @license See the LICENSE file. */ | ||
declare const version = "2.3.0"; | ||
declare const version = "2.4.0"; | ||
export { version }; |
/** @license See the LICENSE file. */ | ||
// This code is auto-generated, do not modify this file! | ||
const version = '2.3.0'; | ||
const version = '2.4.0'; | ||
export { version }; | ||
//# sourceMappingURL=version.js.map |
@@ -26,4 +26,5 @@ /** | ||
* Enforce use of half precision textures if available on the platform. | ||
* | ||
* @doc {heading: 'Environment', namespace: 'webgl'} | ||
*/ | ||
/** @doc {heading: 'Environment', namespace: 'webgl'} */ | ||
export declare function forceHalfFloat(): void; |
@@ -27,4 +27,5 @@ /** | ||
* Enforce use of half precision textures if available on the platform. | ||
* | ||
* @doc {heading: 'Environment', namespace: 'webgl'} | ||
*/ | ||
/** @doc {heading: 'Environment', namespace: 'webgl'} */ | ||
export function forceHalfFloat() { | ||
@@ -31,0 +32,0 @@ env().set('WEBGL_FORCE_F16_TEXTURES', true); |
{ | ||
"name": "@tensorflow/tfjs-backend-webgl", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "GPU accelerated WebGL backend for TensorFlow.js", | ||
@@ -26,3 +26,3 @@ "private": false, | ||
"@rollup/plugin-typescript": "^3.0.0", | ||
"@tensorflow/tfjs-core": "2.3.0", | ||
"@tensorflow/tfjs-core": "2.4.0", | ||
"@types/jasmine": "~3.0.0", | ||
@@ -71,3 +71,3 @@ "clang-format": "~1.2.4", | ||
"dependencies": { | ||
"@tensorflow/tfjs-backend-cpu": "2.3.0", | ||
"@tensorflow/tfjs-backend-cpu": "2.4.0", | ||
"@types/offscreencanvas": "~2019.3.0", | ||
@@ -80,3 +80,3 @@ "@types/seedrandom": "2.4.27", | ||
"peerDependencies": { | ||
"@tensorflow/tfjs-core": "2.3.0" | ||
"@tensorflow/tfjs-core": "2.4.0" | ||
}, | ||
@@ -83,0 +83,0 @@ "browser": { |
@@ -29,6 +29,3 @@ /** | ||
firstPass: boolean) { | ||
const windowSize = reduceInfo.windowSize; | ||
const batchSize = reduceInfo.batchSize; | ||
const inSize = reduceInfo.inSize; | ||
const outSize = Math.ceil(inSize / windowSize); | ||
const {windowSize, batchSize, outSize} = reduceInfo; | ||
if (!firstPass) { | ||
@@ -35,0 +32,0 @@ this.variableNames.push('bestIndicesA'); |
@@ -25,16 +25,42 @@ /** | ||
// Returns an array of configuration objects that describe each stage of the | ||
// reduction. | ||
function getReductionStages(inShape: number[]): | ||
Array<{inSize: number, windowSize: number, outSize: number}> { | ||
const stages = []; | ||
while (stages.length === 0 || stages[stages.length - 1].outSize !== 1) { | ||
const outSize: number = | ||
stages.length ? stages[stages.length - 1].outSize : inShape[1]; | ||
const windowSize = backend_util.computeOptimalWindowSize(outSize); | ||
stages.push({ | ||
inSize: outSize, | ||
windowSize, | ||
outSize: Math.ceil(outSize / windowSize) | ||
}); | ||
} | ||
return stages; | ||
} | ||
export function reduce( | ||
x: TensorInfo, dtype: DataType, reductionType: ReduceTypes, | ||
backend: MathBackendWebGL): TensorInfo { | ||
const [batchSize, inSize] = x.shape; | ||
const windowSize = backend_util.computeOptimalWindowSize(inSize); | ||
const reduceInfo = {windowSize, inSize, batchSize}; | ||
const program = new ReduceProgram(reduceInfo, reductionType); | ||
const output = backend.runWebGLProgram(program, [x], dtype); | ||
const reductionStages = getReductionStages(x.shape); | ||
if (output.shape[1] === 1) { | ||
return output; | ||
let result = x; | ||
for (let i = 0; i < reductionStages.length; i++) { | ||
const {inSize, windowSize, outSize} = reductionStages[i]; | ||
const program = new ReduceProgram( | ||
{windowSize, inSize, batchSize: x.shape[0], outSize}, reductionType); | ||
const previousResult = result; | ||
result = backend.runWebGLProgram(program, [result], dtype); | ||
if (previousResult.dataId !== x.dataId) { | ||
backend.disposeData(previousResult.dataId); | ||
} | ||
} | ||
return reduce(output, dtype, reductionType, backend); | ||
return result; | ||
} |
@@ -29,6 +29,3 @@ /** | ||
reduceType: 'all'|'any'|'max'|'min'|'sum'|'prod') { | ||
const windowSize = reduceInfo.windowSize; | ||
const batchSize = reduceInfo.batchSize; | ||
const inSize = reduceInfo.inSize; | ||
const outSize = Math.ceil(inSize / windowSize); | ||
const {windowSize, batchSize, inSize, outSize} = reduceInfo; | ||
this.outputShape = [batchSize, outSize]; | ||
@@ -35,0 +32,0 @@ |
/** @license See the LICENSE file. */ | ||
// This code is auto-generated, do not modify this file! | ||
const version = '2.3.0'; | ||
const version = '2.4.0'; | ||
export {version}; |
@@ -32,6 +32,7 @@ /** | ||
* Enforce use of half precision textures if available on the platform. | ||
* | ||
* @doc {heading: 'Environment', namespace: 'webgl'} | ||
*/ | ||
/** @doc {heading: 'Environment', namespace: 'webgl'} */ | ||
export function forceHalfFloat(): void { | ||
env().set('WEBGL_FORCE_F16_TEXTURES', true); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8929014
472
62711
+ Added@tensorflow/tfjs-backend-cpu@2.4.0(transitive)
+ Added@tensorflow/tfjs-core@2.4.0(transitive)
- Removed@tensorflow/tfjs-backend-cpu@2.3.0(transitive)
- Removed@tensorflow/tfjs-core@2.3.0(transitive)