Skip to content

Commit 3733fe0

Browse files
authored
Merge branch 'master' into patch-1
2 parents 74fa302 + 7a657b8 commit 3733fe0

File tree

108 files changed

+3726
-585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3726
-585
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ deps/
2626
dist/
2727
tfjs-layers/integration_tests/tfjs2keras/test-data/
2828
tfjs-layers/integration/typescript/yarn.lock
29+
30+
# Ignore the src, binding, scripts of tfjs-node-gpu since it is copied over when
31+
# building.
32+
/tfjs-node-gpu/src
33+
/tfjs-node-gpu/binding
34+
/tfjs-node-gpu/scripts
35+
/tfjs-node-gpu/binding.gyp
36+
2937
lib/
3038
local.log
3139
node_modules/

cloudbuild.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ steps:
1111
id: 'diff'
1212
args: ['diff']
1313
waitFor: ['yarn']
14+
env:
15+
- 'COMMIT_SHA=$COMMIT_SHA'
16+
- 'BRANCH_NAME=$BRANCH_NAME'
1417

1518
# Core.
1619
- name: 'gcr.io/cloud-builders/gcloud'
@@ -68,13 +71,20 @@ steps:
6871
args: ['./scripts/run-build.sh', 'tfjs-react-native']
6972
waitFor: ['diff']
7073

71-
# Node.
74+
# Node CPU.
7275
- name: 'gcr.io/cloud-builders/gcloud'
7376
entrypoint: 'bash'
7477
id: 'tfjs-node'
7578
args: ['./scripts/run-build.sh', 'tfjs-node']
7679
waitFor: ['diff']
7780

81+
# Node GPU.
82+
- name: 'gcr.io/cloud-builders/gcloud'
83+
entrypoint: 'bash'
84+
id: 'tfjs-node-gpu'
85+
args: ['./scripts/run-build.sh', 'tfjs-node-gpu']
86+
waitFor: ['diff']
87+
7888
# Integration tests
7989
- name: 'node:10'
8090
dir: 'tfjs-core'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"chalk": "~2.4.2",
55
"shelljs": "~0.8.3",
66
"ts-node": "~4.1.0",
7+
"tslint": "~5.20.0",
78
"typescript": "3.5.3"
89
},
910
"scripts": {

scripts/diff.js

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// =============================================================================
1616

1717
const {exec} = require('./test-util');
18+
const shell = require('shelljs');
1819
const {readdirSync, statSync, writeFileSync} = require('fs');
1920
const {join} = require('path');
2021
const fs = require('fs');
@@ -30,9 +31,45 @@ const dirs = readdirSync('.').filter(f => {
3031
return f !== 'node_modules' && f !== '.git' && statSync(f).isDirectory();
3132
});
3233

33-
exec(
34-
`git clone --depth=1 --single-branch ` +
35-
`https://github.com/tensorflow/tfjs ${CLONE_PATH}`);
34+
let commitSha = process.env['COMMIT_SHA'];
35+
let branchName = process.env['BRANCH_NAME'];
36+
// If commit sha or branch name are null we are running this locally and are in
37+
// a git repository.
38+
if (commitSha == null) {
39+
commitSha = exec(`git rev-parse HEAD`).stdout.trim();
40+
}
41+
if (branchName == null) {
42+
branchName = exec(`git rev-parse --abbrev-ref HEAD`).stdout.trim();
43+
}
44+
console.log('commitSha: ', commitSha);
45+
console.log('branchName: ', branchName);
46+
47+
// We cannot do --depth=1 here because we need to check out an old merge base.
48+
// We cannot do --single-branch here because we need multiple branches.
49+
exec(`git clone https://github.com/tensorflow/tfjs ${CLONE_PATH}`);
50+
51+
console.log(); // Break up the console for readability.
52+
53+
shell.cd(CLONE_PATH);
54+
55+
// If we cannot check out the commit then this PR is coming from a fork.
56+
const res = shell.exec(`git checkout ${commitSha}`, {silent: true});
57+
const isPullRequestFromFork = res.code !== 0;
58+
59+
// Only checkout the merge base if the pull requests comes from a
60+
// tensorflow/tfjs branch. Otherwise clone master and diff against master.
61+
if (!isPullRequestFromFork) {
62+
console.log('PR is coming from tensorflow/tfjs. Finding the merge base...');
63+
exec(`git checkout ${branchName}`);
64+
const mergeBase = exec(`git merge-base master ${branchName}`).stdout.trim();
65+
exec(`git fetch origin ${mergeBase}`);
66+
exec(`git checkout ${mergeBase}`);
67+
console.log('mergeBase: ', mergeBase);
68+
} else {
69+
console.log('PR is coming from a fork. Diffing against master.');
70+
}
71+
shell.cd('..');
72+
console.log(); // Break up the console for readability.
3673

3774
let triggerAllBuilds = false;
3875
let whitelistDiffOutput = [];
@@ -45,11 +82,11 @@ filesWhitelistToTriggerBuild.forEach(fileToTriggerBuild => {
4582
}
4683
});
4784

48-
// Break up the console for readability.
49-
console.log();
85+
console.log(); // Break up the console for readability.
5086

5187
let triggeredBuilds = [];
5288
dirs.forEach(dir => {
89+
shell.rm('-f', `${dir}/diff`);
5390
const diffOutput = diff(`${dir}/`);
5491
if (diffOutput !== '') {
5592
console.log(`${dir} has modified files.`);
@@ -65,16 +102,17 @@ dirs.forEach(dir => {
65102
}
66103
});
67104

68-
// Break up the console for readability.
69-
console.log();
105+
console.log(); // Break up the console for readability.
70106

71-
// Filter the triggered builds to log by whether a cloudbuild.yml file exists
72-
// for that directory.
107+
// Filter the triggered builds to log by whether a cloudbuild.yml file
108+
// exists for that directory.
73109
triggeredBuilds = triggeredBuilds.filter(
74110
triggeredBuild => fs.existsSync(triggeredBuild + '/cloudbuild.yml'));
75111
console.log('Triggering builds for ', triggeredBuilds.join(', '));
76112

77113
function diff(fileOrDirName) {
78-
const diffCmd = `diff -rq ${CLONE_PATH}/${fileOrDirName} ./${fileOrDirName}`;
114+
const diffCmd = `diff -rq ` +
115+
`${CLONE_PATH}/${fileOrDirName} ` +
116+
`${fileOrDirName}`;
79117
return exec(diffCmd, {silent: true}, true).stdout.trim();
80118
}

scripts/publish-npm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fi
6262
./scripts/make-version.js $1
6363

6464
cd $1
65-
yarn build-npm
65+
yarn build-npm for-publish
6666
cd ..
6767

6868
./scripts/tag-version.js $1

tfjs-automl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorflow/tfjs-automl",
3-
"version": "0.0.1-alpha.0",
3+
"version": "0.0.1-alpha.1",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"module": "dist/tf-automl.esm.js",

tfjs-automl/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @license See the LICENSE file. */
22

33
// This code is auto-generated, do not modify this file!
4-
const version = '0.0.1-alpha.0';
4+
const version = '0.0.1-alpha.1';
55
export {version};

tfjs-backend-webgpu/benchmarks/main.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ h2 {
111111
}
112112

113113
.color {
114-
border-radius: 50%;
115-
width: 10px;
116-
height: 10px;
114+
width: 20px;
115+
height: 2px;
117116
display: inline-block;
118117
vertical-align: middle;
119118
}

tfjs-backend-webgpu/benchmarks/main.js

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,52 @@
1616
*/
1717

1818
const swatches = {
19-
'webgpu_min': '#FCA521',
19+
'webgpu_min': '#F1523E',
2020
'webgpu_mean': '#F1523E',
21-
'webgl_min': '#03A698',
22-
'webgl_mean': '#025952'
21+
'webgl_min': '#3f51b5',
22+
'webgl_mean': '#3f51b5'
2323
};
2424

25+
const strokes = {
26+
'webgpu_min': '2',
27+
'webgpu_mean': '0',
28+
'webgl_min': '2',
29+
'webgl_mean': '0'
30+
};
31+
32+
const MAX_NUM_LOGS = 50;
2533
const START_LOGGING_DATE = '2019-08-16';
2634
const startDate = moment(START_LOGGING_DATE, 'YYYY-MM-DD');
2735
const endDate = moment();
2836
const files = [];
2937
let dateFormats = [];
30-
const daysElapsed = endDate.diff(startDate, 'd')
31-
for (let i = 0; i <= daysElapsed; i++) {
38+
const daysElapsed = endDate.diff(startDate, 'd');
39+
let interval = 1;
40+
41+
while (daysElapsed / interval > MAX_NUM_LOGS) {
42+
interval += 1;
43+
}
44+
45+
for (let i = 0; i <= daysElapsed; i += interval) {
3246
const current = startDate.clone().add(i, 'days');
3347
files.push(`${current.format('MM_DD_YYYY')}`);
3448
dateFormats.push(current.format('M/DD'));
3549
}
3650

51+
function getSwatchBackground(swatch, stroke) {
52+
let background = swatch;
53+
if (stroke > 0) {
54+
background = `repeating-linear-gradient(
55+
to right,
56+
${swatch},
57+
${swatch} 2px,
58+
white 2px,
59+
white 4px
60+
);`;
61+
}
62+
return background;
63+
}
64+
3765
Promise
3866
.all(files.map(
3967
d =>
@@ -143,16 +171,19 @@ Promise
143171
}
144172

145173
const xIncrement = chartWidth / (test.entries.length - 1);
146-
147174
const template = // template trendlines
148175
`<div class='test'>
149176
<h4 class='test-name'>${test.name}</h4>
150177
<div class='legend'>${
151178
Object.keys(params)
152179
.map((param, i) => {
153180
return `<div class='swatch'>
154-
<div class='color' style='background-color:
155-
${swatches[param]}'></div> <div class='label'>${
181+
<div class='color' style='background:
182+
${
183+
getSwatchBackground(
184+
swatches[param],
185+
strokes
186+
[param])}'></div> <div class='label'>${
156187
param}</div>
157188
</div>`;
158189
})
@@ -165,8 +196,9 @@ Promise
165196
<svg data-index=${i} class='graph' width='${
166197
chartWidth}' height='${chartHeight}'>${
167198
Object.keys(params).map(
168-
(param,
169-
i) => `<path stroke='${swatches[param]}' d='M${
199+
(param, i) => `<path stroke-dasharray='${
200+
strokes[param]}' stroke='${
201+
swatches[param]}' d='M${
170202
params[param]
171203
.map(
172204
(d, i) => `${i * xIncrement},${
@@ -229,8 +261,9 @@ Promise
229261
.params
230262
.map(
231263
(d, i) => {return `<div class='label-wrapper'>
232-
<div class='color' style='background-color: ${
233-
swatches[d.name]}'></div>
264+
<div class='color' style='background: ${
265+
getSwatchBackground(
266+
swatches[d.name], strokes[d.name])}'></div>
234267
<div class='label'>${d.ms}</div>
235268
</div>`})
236269
.join(' ')}

tfjs-backend-webgpu/cloudbuild.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
steps:
22
# Install common dependencies.
33
- name: 'node:10'
4-
dir: 'tfjs-backend-webgpu'
54
id: 'yarn-common'
65
entrypoint: 'yarn'
76
args: ['install']
87

98
# Install webgpu dependencies.
9+
- name: 'node:10'
10+
dir: 'tfjs-backend-webgpu'
11+
id: 'yarn'
12+
entrypoint: 'yarn'
13+
args: ['install']
14+
waitFor: ['yarn-common']
15+
16+
# Run tests.
1017
- name: 'node:10'
1118
dir: 'tfjs-backend-webgpu'
1219
entrypoint: 'yarn'
1320
id: 'test-webgpu'
1421
args: ['test-ci']
15-
waitFor: ['yarn-common']
22+
waitFor: ['yarn']
1623

1724
# General configuration
1825
timeout: 1800s

0 commit comments

Comments
 (0)