Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 29 additions & 10 deletions tfjs-converter/cloudbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,46 @@ steps:
id: 'yarn-common'
args: ['install']

# Install converter dependencies
# Install converter dependencies.
- name: 'node:10'
dir: 'tfjs-converter'
entrypoint: 'yarn'
id: 'yarn'
args: ['install']
waitFor: ['yarn-common']

# Run browser tests.
# Run lint.
- name: 'node:10'
dir: 'tfjs-converter'
entrypoint: 'yarn'
id: 'test-browser'
args: ['test-ci']
id: 'lint'
args: ['lint']
waitFor: ['yarn']

# Generate json file.
- name: 'node:10'
dir: 'tfjs-converter'
entrypoint: 'yarn'
id: 'gen-json'
args: ['gen-json', '--test']
waitFor: ['yarn']
env: ['BROWSERSTACK_USERNAME=deeplearnjs1', 'NIGHTLY=$_NIGHTLY']
secretEnv: ['BROWSERSTACK_KEY']

# Build the project.
- name: 'node:10'
dir: 'tfjs-converter'
entrypoint: 'yarn'
id: 'build'
args: ['build']
waitFor: ['gen-json']

# Run javascript tests.
- name: 'node:10'
dir: 'tfjs-converter'
entrypoint: 'yarn'
id: 'test-js'
args: ['test-ci']
waitFor: ['build']
env: ['NIGHTLY=$_NIGHTLY']

# Run python tests.
- name: 'gcr.io/google-appengine/python'
Expand Down Expand Up @@ -50,10 +73,6 @@ steps:
args: ['test-snippets']
waitFor: ['yarn']

secrets:
- kmsKeyName: projects/learnjs-174218/locations/global/keyRings/tfjs/cryptoKeys/enc
secretEnv:
BROWSERSTACK_KEY: CiQAkwyoIW0LcnxymzotLwaH4udVTQFBEN4AEA5CA+a3+yflL2ASPQAD8BdZnGARf78MhH5T9rQqyz9HNODwVjVIj64CTkFlUCGrP1B2HX9LXHWHLmtKutEGTeFFX9XhuBzNExA=
timeout: 1800s
logsBucket: 'gs://tfjs-build-logs'
substitutions:
Expand Down
5 changes: 2 additions & 3 deletions tfjs-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@
"build-npm": "./scripts/build-npm.sh",
"link-local": "yalc link",
"publish-local": "yarn build-npm && yalc push",
"test": "yarn gen-json --test && karma start",
"test-ci": "yarn gen-json --test && yarn build && yarn lint && yarn run-browserstack",
"test": "yarn gen-json --test && ts-node run_tests.ts",
"test-ci": "ts-node run_tests.ts",
"test-snippets": "ts-node ./scripts/test_snippets.ts",
"run-browserstack": "karma start --singleRun --browsers='bs_firefox_mac,bs_chrome_mac' --reporters='dots,karma-typescript,BrowserStack'",
"lint": "tslint -p . -t verbose",
"make-version": "sh -c ./scripts/make-version",
"gen-doc": "ts-node ./scripts/gen_doc.ts",
Expand Down
38 changes: 38 additions & 0 deletions tfjs-converter/run_tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2020 Google Inc. 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.
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util';

// tslint:disable-next-line:no-require-imports
const jasmineCtor = require('jasmine');
// tslint:disable-next-line:no-require-imports

Error.stackTraceLimit = Infinity;

process.on('unhandledRejection', e => {
throw e;
});

jasmine_util.setTestEnvs(
[{name: 'test-converter', backendName: 'cpu', flags: {}}]);

const unitTests = 'src/**/*_test.ts';

const runner = new jasmineCtor();
runner.loadConfig({spec_files: [unitTests], random: false});
runner.execute();
10 changes: 5 additions & 5 deletions tfjs-converter/src/operations/executors/dynamic_executor_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('dynamic', () => {
const input3 = [tfc.tensor1d([1])];
const input4 = [tfc.tensor1d([1])];
const input5 = [tfc.tensor1d([1])];
spyOn(tfc.image, 'nonMaxSuppressionAsync').and.callThrough();
spyOn(tfc.image, 'nonMaxSuppressionAsync');
const result =
executeOp(node, {input1, input2, input3, input4, input5}, context);
expect(tfc.image.nonMaxSuppressionAsync)
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('dynamic', () => {
const input3 = [tfc.tensor1d([1])];
const input4 = [tfc.tensor1d([1])];
const input5 = [tfc.tensor1d([1])];
spyOn(tfc.image, 'nonMaxSuppressionAsync').and.callThrough();
spyOn(tfc.image, 'nonMaxSuppressionAsync');
const result =
executeOp(node, {input1, input2, input3, input4, input5}, context);
expect(tfc.image.nonMaxSuppressionAsync)
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('dynamic', () => {
const input4 = [tfc.tensor1d([1])];
const input5 = [tfc.tensor1d([1])];
const input6 = [tfc.tensor1d([1])];
spyOn(tfc.image, 'nonMaxSuppressionWithScoreAsync').and.callThrough();
spyOn(tfc.image, 'nonMaxSuppressionWithScoreAsync').and.returnValue({});
const result = executeOp(
node, {input1, input2, input3, input4, input5, input6}, context);
expect(tfc.image.nonMaxSuppressionWithScoreAsync)
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('dynamic', () => {
node.op = 'Where';
node.inputParams = {'condition': createTensorAttr(0)};
const input1 = [tfc.scalar(1)];
spyOn(tfc, 'whereAsync').and.callThrough();
spyOn(tfc, 'whereAsync');

const result = executeOp(node, {input1}, context);
expect((tfc.whereAsync as jasmine.Spy).calls.mostRecent().args[0].dtype)
Expand All @@ -180,7 +180,7 @@ describe('dynamic', () => {
node.inputParams = {'x': createTensorAttr(0), 'y': createTensorAttr(1)};
const input1 = [tfc.scalar(1)];
const input2 = [tfc.scalar(1)];
spyOn(tfc, 'setdiff1dAsync').and.callThrough();
spyOn(tfc, 'setdiff1dAsync');

const result = executeOp(node, {input1, input2}, context);
expect(tfc.setdiff1dAsync).toHaveBeenCalledWith(input1[0], input2[0]);
Expand Down