Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8f6d3da
Upgrade typescript to 4.4.2
mattsoulanille Aug 27, 2021
9dc3322
[core] Upgrade typescript to 4.4.2
mattsoulanille Aug 27, 2021
24e9353
Install tslib
mattsoulanille Aug 27, 2021
ea630b5
[webgl] Upgrade typescript to 4.4.2
mattsoulanille Aug 27, 2021
add0110
[wasm] Upgrade typescript to 4.4.2
mattsoulanille Aug 27, 2021
973cb6b
[layers] Update typescript to 4.4.2
mattsoulanille Aug 27, 2021
3d95906
[data] Update typescript to 4.4.2
mattsoulanille Aug 30, 2021
f482727
[tfjs-automl] Update typescript to 4.4.2
mattsoulanille Aug 30, 2021
d6cc93a
[inference] Upgrade TypeScript to 4.4.2
mattsoulanille Aug 31, 2021
68b6898
[cpu] Update package.json with ts 4.4.2
mattsoulanille Aug 31, 2021
76fb265
[converter] Fix executor tests to work with ts 4
mattsoulanille Aug 31, 2021
a2ca980
[converter] Update kenrels_to_ops to work with new mocked tfOps
mattsoulanille Nov 3, 2021
ec8a585
[converter] Fix graph model tests by using spyOnAllFunctions
mattsoulanille Nov 3, 2021
e695e22
[converter] Fix executeOp tests by using a tfc.tidy spy
mattsoulanille Nov 3, 2021
1cf25af
Fix lint errors
mattsoulanille Nov 3, 2021
ea8fb41
[union] Upgrade typescript to 4.4.2
mattsoulanille Nov 4, 2021
a70df89
[node] Upgrade typescript to 4.4.2
mattsoulanille Nov 4, 2021
db2c0a2
[tflite] Upgrade typescript to 4.4.2
mattsoulanille Nov 4, 2021
a3dce77
[e2e] Upgrade typescript to 4.4.2
mattsoulanille Nov 4, 2021
2eee6ae
[vis] Set sort to null instead of false
mattsoulanille Nov 10, 2021
29e8a79
fixup! [converter] Fix executor tests to work with ts 4
mattsoulanille Nov 10, 2021
1722513
fixup! [data] Update typescript to 4.4.2
mattsoulanille Nov 11, 2021
cdfcc35
[converter] Fix Cumprod and ImageProjectiveTransformV3 tests
mattsoulanille Apr 22, 2022
295fac6
[react-native] Upgrade typescript to 4.4.2
mattsoulanille Apr 23, 2022
5653bf1
[converter] Remove unnecessary module_name from converter tests
mattsoulanille Jun 23, 2022
23ed16a
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Jun 23, 2022
24724cc
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Jun 23, 2022
3dcdf06
Fix lint
mattsoulanille Jun 23, 2022
c0e8be0
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Sep 30, 2022
a8930ff
Fix tslint errors
mattsoulanille Sep 30, 2022
b8791f9
Ignore OffscreenCanvas type errors in fromPixels worker test
mattsoulanille Sep 30, 2022
dd1e73f
Upgrade non-bazel pacakges from ts 4.4.2 to 4.8.4
mattsoulanille Sep 30, 2022
f893884
Ignore OffscreenCanvas type errors in webgpu FromPixels kernel
mattsoulanille Sep 30, 2022
13faefd
[union] Upgrade rollup packages
mattsoulanille Sep 30, 2022
2a3963f
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Oct 4, 2022
cff38a4
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Oct 4, 2022
cc34e38
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
mattsoulanille Oct 5, 2022
d9e5d5d
Fix union package tools tests
mattsoulanille Oct 5, 2022
8eac36f
[vis] Fix not waiting for the histogram to be added in histogram test
mattsoulanille Oct 5, 2022
dc6de9c
Upgrade tfjs-vis to typescript 4.8.4
mattsoulanille Oct 5, 2022
fe6ec5d
Update karma-typescript
mattsoulanille Oct 11, 2022
d7cfe92
Add @types/offscreencanvas
mattsoulanille Oct 11, 2022
08908b1
Restore null check in test-snippets util.ts
mattsoulanille Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into tfjs-typescript-4
  • Loading branch information
mattsoulanille committed Sep 30, 2022
commit c0e8be0d8de9a79c4fa4abe9f45d48c779f35124
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"@types/mkdirp": "^0.5.2",
"@types/node": "^12.7.5",
"@types/node-fetch": "~2.1.2",
"@types/offscreencanvas": "~2019.3.0",
"@types/offscreencanvas": "~2019.7.0",
"@types/rollup-plugin-visualizer": "^4.2.1",
"@types/seedrandom": "^2.4.28",
"@types/shelljs": "^0.8.7",
"@types/webgl-ext": "0.0.30",
"@types/webgl2": "0.0.6",
"@webgpu/types": "0.1.16",
"@webgpu/types": "0.1.21",
"ajv": "~6.12.3",
"argparse": "^1.0.10",
"chalk": "~2.4.2",
Expand Down Expand Up @@ -68,7 +68,7 @@
"tslib": "^2.4.0",
"tslint": "^6.1.3",
"tslint-no-circular-imports": "~0.7.0",
"typescript": "4.4.2"
"typescript": "4.8.4"
},
"scripts": {
"lint": "tslint -p tsconfig_tslint.json",
Expand Down
2 changes: 1 addition & 1 deletion tfjs-backend-webgl/src/canvas_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function getWebGLRenderingContext(

if (webGLVersion === 1) {
return (canvas.getContext('webgl', WEBGL_ATTRIBUTES) ||
canvas.getContext('experimental-webgl', WEBGL_ATTRIBUTES)) as
(canvas as HTMLCanvasElement).getContext('experimental-webgl', WEBGL_ATTRIBUTES)) as
WebGLRenderingContext;
}
return canvas.getContext('webgl2', WEBGL_ATTRIBUTES) as WebGLRenderingContext;
Expand Down
9 changes: 5 additions & 4 deletions tfjs-converter/src/executor/graph_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class GraphModel<ModelURL extends Url = string | io.IOHandler> implements
private initializer: GraphExecutor;
private resourceManager: ResourceManager;
private signature: tensorflow.ISignatureDef;
private structuredOutputKeys: string[];
private readonly io: typeof io;

// Returns the version information for the tensorflow model GraphDef.
Expand Down Expand Up @@ -97,8 +98,8 @@ export class GraphModel<ModelURL extends Url = string | io.IOHandler> implements
* before the load is completed.
*/
constructor(
private modelUrl: ModelURL,
private loadOptions: io.LoadOptions = {}, tfio = io) {
private modelUrl: ModelURL, private loadOptions: io.LoadOptions = {},
tfio = io) {
this.io = tfio;
if (loadOptions == null) {
this.loadOptions = {};
Expand All @@ -113,8 +114,8 @@ export class GraphModel<ModelURL extends Url = string | io.IOHandler> implements
// Path is an IO Handler.
this.handler = path as IOHandler;
} else if (this.loadOptions.requestInit != null) {
this.handler = this.io
.browserHTTPRequest(path as string, this.loadOptions) as IOHandler;
this.handler = this.io.browserHTTPRequest(
path as string, this.loadOptions) as IOHandler;
} else {
const handlers =
this.io.getLoadHandlers(path as string, this.loadOptions);
Expand Down
30 changes: 8 additions & 22 deletions tfjs-converter/src/executor/graph_model_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {RecursiveSpy, spyOnAllFunctions} from '../operations/executors/spy_ops';
import {GraphNode} from '../operations/types';

import {GraphModel, loadGraphModel, loadGraphModelSync} from './graph_model';
import {RecursiveSpy, spyOnAllFunctions} from '../operations/executors/spy_ops';
import {STRUCTURED_OUTPUTS_MODEL} from './test_data/structured_outputs_model_loader';

const HOST = 'http://example.org';
const MODEL_URL = `${HOST}/model.json`;
Expand Down Expand Up @@ -418,9 +418,7 @@ describe('loadGraphModel', () => {

it('Pass a fetchFunc', async () => {
const fetchFunc = () => {};
spyIo.getLoadHandlers.and.returnValue([
CUSTOM_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([CUSTOM_HTTP_MODEL_LOADER]);
await loadGraphModel(MODEL_URL, {fetchFunc}, spyIo);
expect(spyIo.getLoadHandlers).toHaveBeenCalledWith(MODEL_URL, {fetchFunc});
});
Expand Down Expand Up @@ -466,9 +464,7 @@ describe('Model', () => {

describe('custom model', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
CUSTOM_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([CUSTOM_HTTP_MODEL_LOADER]);
registerOp('CustomOp', (nodeValue: GraphNode) => {
const x = nodeValue.inputs[0];
return [tfc.add(x, scalar(1, 'int32'))];
Expand Down Expand Up @@ -508,9 +504,7 @@ describe('Model', () => {

describe('simple model', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
SIMPLE_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([SIMPLE_HTTP_MODEL_LOADER]);
spyIo.browserHTTPRequest.and.returnValue(SIMPLE_HTTP_MODEL_LOADER);
});
it('load', async () => {
Expand Down Expand Up @@ -771,9 +765,7 @@ describe('Model', () => {

describe('control flow model', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
CONTROL_FLOW_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([CONTROL_FLOW_HTTP_MODEL_LOADER]);
spyIo.browserHTTPRequest.and.returnValue(CONTROL_FLOW_HTTP_MODEL_LOADER);
});

Expand Down Expand Up @@ -861,9 +853,7 @@ describe('Model', () => {
};
describe('dynamic shape model', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
DYNAMIC_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([DYNAMIC_HTTP_MODEL_LOADER]);
spyIo.browserHTTPRequest.and.returnValue(DYNAMIC_HTTP_MODEL_LOADER);
});

Expand Down Expand Up @@ -905,9 +895,7 @@ describe('Model', () => {
});
describe('dynamic shape model with metadata', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
DYNAMIC_HTTP_MODEL_NEW_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([DYNAMIC_HTTP_MODEL_NEW_LOADER]);
spyIo.browserHTTPRequest.and.returnValue(DYNAMIC_HTTP_MODEL_NEW_LOADER);
});

Expand All @@ -930,9 +918,7 @@ describe('Model', () => {

describe('Hashtable model', () => {
beforeEach(() => {
spyIo.getLoadHandlers.and.returnValue([
HASHTABLE_HTTP_MODEL_LOADER
]);
spyIo.getLoadHandlers.and.returnValue([HASHTABLE_HTTP_MODEL_LOADER]);
spyIo.browserHTTPRequest.and.returnValue(HASHTABLE_HTTP_MODEL_LOADER);
});
it('should be successful if call executeAsync', async () => {
Expand Down
8 changes: 5 additions & 3 deletions tfjs-converter/src/operations/executors/creation_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {InternalOpExecutor, Node} from '../types';
import {getParamValue} from './utils';

export const executeOp: InternalOpExecutor =
(node: Node, tensorMap: NamedTensorsMap,
context: ExecutionContext, ops = tfOps): Tensor[] => {
(node: Node, tensorMap: NamedTensorsMap, context: ExecutionContext,
ops = tfOps): Tensor[] => {
switch (node.op) {
case 'Fill': {
const shape =
Expand Down Expand Up @@ -64,7 +64,9 @@ export const executeOp: InternalOpExecutor =
getParamValue('onValue', node, tensorMap, context) as number;
const offValue =
getParamValue('offValue', node, tensorMap, context) as number;
return [ops.oneHot(indices, depth, onValue, offValue)];
const dtype =
getParamValue('dtype', node, tensorMap, context) as DataType;
return [ops.oneHot(indices, depth, onValue, offValue, dtype)];
}
case 'Ones': {
return [ops.ones(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {Node} from '../types';
import {executeOp} from './creation_executor';
import {RecursiveSpy, spyOnAllFunctions} from './spy_ops';
import {createDtypeAttr, createNumberAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createTensorAttr, validateParam} from './test_helper';
import {spyOnAllFunctions, RecursiveSpy} from './spy_ops';

describe('creation', () => {
let node: Node;
Expand Down Expand Up @@ -106,10 +105,11 @@ describe('creation', () => {
const input3 = [tfOps.scalar(2)];
const input4 = [tfOps.scalar(3)];
spyOps.oneHot.and.returnValue({});
executeOp(node, {input, input2, input3, input4}, context,
spyOpsAsTfOps);
executeOp(
node, {input, input2, input3, input4}, context, spyOpsAsTfOps);

expect(spyOps.oneHot).toHaveBeenCalledWith(input[0], 1, 2, 3);
expect(spyOps.oneHot)
.toHaveBeenCalledWith(input[0], 1, 2, 3, 'float32');
});
it('should match json def', () => {
node.op = 'OneHot';
Expand Down
41 changes: 28 additions & 13 deletions tfjs-converter/src/operations/executors/spy_ops.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
export type RecursiveSpy<T> = T extends Function ? jasmine.Spy : {
[K in keyof T]: RecursiveSpy<T[K]>
};
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

export type RecursiveSpy<T> =
T extends Function ? jasmine.Spy : {[K in keyof T]: RecursiveSpy<T[K]>};

export function spyOnAllFunctions<T>(obj: T): RecursiveSpy<T> {
return Object.fromEntries(
Object.entries(obj).map(([key, val]) => {
if (val instanceof Function) {
return [key, jasmine.createSpy(`${key} spy`, val).and.callThrough()];
} else if (val instanceof Array) {
return [key, val];
} else if (val instanceof Object) {
return [key, spyOnAllFunctions(val)];
}
return Object.fromEntries(Object.entries(obj).map(([key, val]) => {
if (val instanceof Function) {
return [key, jasmine.createSpy(`${key} spy`, val).and.callThrough()];
} else if (val instanceof Array) {
return [key, val];
})) as RecursiveSpy<T>;
} else if (val instanceof Object) {
return [key, spyOnAllFunctions(val)];
}
return [key, val];
})) as RecursiveSpy<T>;
}
2 changes: 1 addition & 1 deletion tfjs-converter/src/operations/operation_executor_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('OperationExecutor', () => {
const tidySpy = jasmine.createSpy('tidy spy', tfc.tidy);

node.category = category.CATEGORY;
executeOp(node, {}, context, undefined, tidySpy);
executeOp(node, {}, context, undefined, tidySpy as typeof tfc.tidy);
expect(tidySpy).toHaveBeenCalled();
});
});
Expand Down
4 changes: 2 additions & 2 deletions tfjs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
},
"dependencies": {
"@types/long": "^4.0.1",
"@types/offscreencanvas": "~2019.3.0",
"@types/offscreencanvas": "~2019.7.0",
"@types/seedrandom": "^2.4.28",
"@types/webgl-ext": "0.0.30",
"@webgpu/types": "0.1.16",
"@webgpu/types": "0.1.21",
"long": "4.0.0",
"node-fetch": "~2.6.1",
"seedrandom": "^3.0.5"
Expand Down
2 changes: 2 additions & 0 deletions tfjs-core/src/ops/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ function fromPixels_(
} else if (isImage || isVideo || isImageBitmap) {
if (fromPixels2DContext == null) {
if (typeof document === 'undefined') {
// @ts-ignore
if (typeof OffscreenCanvas !== 'undefined' &&
// @ts-ignore
typeof OffscreenCanvasRenderingContext2D !== 'undefined') {
// @ts-ignore
fromPixels2DContext = new OffscreenCanvas(1, 1).getContext('2d');
Expand Down
5 changes: 3 additions & 2 deletions tfjs-core/src/ops/topk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ function topk_<T extends Tensor>(
const attrs: TopKAttrs = {k, sorted};

const [values, indices] = ENGINE.runKernel(
TopK, inputs as {} as NamedTensorMap, attrs as {} as NamedAttrMap);
TopK, inputs as {} as NamedTensorMap, attrs as {} as NamedAttrMap) as
[T, T];

return {values, indices} as {values: T, indices: T};
return {values, indices};
}

export const topk = op({topk_});
16 changes: 8 additions & 8 deletions tfjs-core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"
integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==

"@types/offscreencanvas@~2019.3.0":
version "2019.3.0"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553"
integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q==
"@types/offscreencanvas@~2019.7.0":
version "2019.7.0"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d"
integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg==

"@types/seedrandom@^2.4.28":
version "2.4.30"
Expand All @@ -32,10 +32,10 @@
resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d"
integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==

"@webgpu/types@^0.1.16":
version "0.1.16"
resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.16.tgz#1f05497b95b7c013facf7035c8e21784645f5cc4"
integrity sha512-9E61voMP4+Rze02jlTXud++Htpjyyk8vw5Hyw9FGRrmhHQg2GqbuOfwf5Klrb8vTxc2XWI3EfO7RUHMpxTj26A==
"@webgpu/[email protected].21":
version "0.1.21"
resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a"
integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==

[email protected]:
version "4.0.0"
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.