-
Notifications
You must be signed in to change notification settings - Fork 2k
Move cpu backend out of tfjs-core #3008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
96c2eb4
move the CPU backend to a top level package
tafsiri 5f82f28
add test runner to backend cpu
tafsiri ee82ec2
small refactor
tafsiri 10e01b5
add backend cpu to cloudbuild
tafsiri 549f151
fix file perms
tafsiri 1423b74
fix test-snippets
tafsiri 9616a99
add secrets
tafsiri 94f068a
save
tafsiri cd1f2ce
save
tafsiri 6cb5546
cleanup
tafsiri 57cff9d
disable cpu testEnv in nightly of core.
tafsiri 1c56c99
add cpu backend as dev dep of converter
tafsiri 136be4a
save
tafsiri 2f9cfe6
save
tafsiri 5adc5c1
save
tafsiri 18dc1ca
exclude web worker test from backend test suite
tafsiri 8801964
converter cloudbuild, run yarn install
tafsiri e0d78c6
add backend-cpu as devDep in data and layers
tafsiri 0a8f8a8
typo
tafsiri 843acc6
typo
tafsiri d0864c6
fix
tafsiri 4631eeb
fix build deps
tafsiri 102ef4b
save
tafsiri 50a1f59
save
tafsiri d70fd2e
typo
tafsiri 77388f8
save
tafsiri 7f541a9
save
tafsiri 3bc1bc1
make sure cpu backend is built in ci
tafsiri a21d48f
restore engine test
tafsiri 5c4224a
circumvent tsc circular import issue
tafsiri b96b1b9
make the kernel and gradient registries global
tafsiri c697c93
reorder build steps
tafsiri bcfbb83
skip test
tafsiri 1fcca7a
add backend to test_snippets
tafsiri 8c0d36d
make test_async_backends use backend from registry
tafsiri e47f0ce
add rollup config for cpu backend
tafsiri 5f0e451
refactor global kernel/grad registries
tafsiri e19cb50
update rollup
tafsiri cf62008
remove unused packages and scripts
tafsiri ba1b18f
code review fixes
tafsiri 7a81d4b
save
tafsiri d887b8d
save
tafsiri 9ead647
Merge branch 'master' into move-cpu-backend
tafsiri 31350ee
fix imports
tafsiri 6e6834a
move pool utils
tafsiri a4b5e41
update scripts
tafsiri 21b2c4f
Merge branch 'master' into move-cpu-backend
tafsiri 0ad2ae2
kick build
tafsiri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| .babelrc | ||
| .DS_Store | ||
| .idea/ | ||
| .rpt2_cache | ||
| .travis.yml | ||
| .vscode | ||
| *.tgz | ||
| *.txt | ||
| **.yalc | ||
| **yalc.lock | ||
| cloudbuild.yml | ||
| coverage/ | ||
| demo/ | ||
| dist/**/*_test.d.ts | ||
| dist/**/*_test.js | ||
| karma.conf.js | ||
| node_modules/ | ||
| npm-debug.log | ||
| package-lock.json | ||
| package/ | ||
| rollup.config.js | ||
| scripts/ | ||
| src/**/*_test.ts | ||
| tsconfig.json | ||
| tslint.json | ||
| yarn-error.log | ||
| yarn.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| package-lock=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| steps: | ||
| # Install common dependencies. | ||
| - name: 'node:10' | ||
| id: 'yarn-common' | ||
| entrypoint: 'yarn' | ||
| args: ['install'] | ||
|
|
||
| # Install webgpu dependencies. | ||
| - name: 'node:10' | ||
| dir: 'tfjs-backend-cpu' | ||
| id: 'yarn' | ||
| entrypoint: 'yarn' | ||
| args: ['install'] | ||
| waitFor: ['yarn-common'] | ||
|
|
||
| # Build core from master. | ||
| - name: 'node:10' | ||
| dir: 'tfjs-backend-cpu' | ||
| id: 'build-core' | ||
| entrypoint: 'yarn' | ||
| args: ['build-core-ci'] | ||
| waitFor: ['yarn-common'] | ||
|
|
||
| # Run tests. | ||
| - name: 'node:10' | ||
| dir: 'tfjs-backend-cpu' | ||
| entrypoint: 'yarn' | ||
| id: 'test-backend-cpu' | ||
| args: ['test-ci'] | ||
| waitFor: ['build-core'] | ||
| env: ['BROWSERSTACK_USERNAME=deeplearnjs1'] | ||
| secretEnv: ['BROWSERSTACK_KEY'] | ||
|
|
||
| # General configuration | ||
| 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: | ||
| _NIGHTLY: '' | ||
| options: | ||
| logStreamingOption: 'STREAM_ON' | ||
| substitution_option: 'ALLOW_LOOSE' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2020 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. | ||
| * ============================================================================= | ||
| */ | ||
|
|
||
| const karmaTypescriptConfig = { | ||
| tsconfig: 'tsconfig.json', | ||
| // Disable coverage reports and instrumentation by default for tests | ||
| coverageOptions: {instrumentation: false}, | ||
| reports: {}, | ||
| bundlerOptions: { | ||
| sourceMap: true, | ||
| // Ignore the import of the `worker_threads` package used in a core test | ||
| // meant to run in node. | ||
| exclude: ['worker_threads'], | ||
| // worker_node_test in tfjs-core contains a conditional require statement | ||
| // that confuses the bundler of karma-typescript. | ||
| ignore: ['./worker_node_test'] | ||
| } | ||
| }; | ||
|
|
||
| module.exports = function(config) { | ||
| const args = []; | ||
| if (config.grep) { | ||
| args.push('--grep', config.grep); | ||
| } | ||
| if (config.flags) { | ||
| args.push('--flags', config.flags); | ||
| } | ||
| let exclude = []; | ||
| if (config.excludeTest != null) { | ||
| exclude.push(config.excludeTest); | ||
| } | ||
|
|
||
| config.set({ | ||
| frameworks: ['jasmine', 'karma-typescript'], | ||
| files: [ | ||
| 'src/setup_test.ts', | ||
| {pattern: 'src/**/*.ts'}, | ||
| ], | ||
| preprocessors: {'**/*.ts': ['karma-typescript']}, | ||
| karmaTypescriptConfig, | ||
| reporters: ['dots', 'karma-typescript'], | ||
| exclude, | ||
| colors: true, | ||
| autoWatch: false, | ||
| browsers: ['Chrome'], | ||
| singleRun: true, | ||
| client: {jasmine: {random: false}, args: args}, | ||
| browserStack: { | ||
| username: process.env.BROWSERSTACK_USERNAME, | ||
| accessKey: process.env.BROWSERSTACK_KEY | ||
| }, | ||
| captureTimeout: 120000, | ||
| reportSlowerThan: 500, | ||
| browserNoActivityTimeout: 240000, | ||
| customLaunchers: { | ||
| // For browserstack configs see: | ||
| // https://www.browserstack.com/automate/node | ||
| bs_chrome_mac: { | ||
| base: 'BrowserStack', | ||
| browser: 'chrome', | ||
| browser_version: 'latest', | ||
| os: 'OS X', | ||
| os_version: 'High Sierra' | ||
| }, | ||
| bs_firefox_mac: { | ||
| base: 'BrowserStack', | ||
| browser: 'firefox', | ||
| browser_version: 'latest', | ||
| os: 'OS X', | ||
| os_version: 'High Sierra' | ||
| }, | ||
| bs_safari_mac: { | ||
| base: 'BrowserStack', | ||
| browser: 'safari', | ||
| browser_version: 'latest', | ||
| os: 'OS X', | ||
| os_version: 'High Sierra' | ||
| }, | ||
| bs_ios_11: { | ||
| base: 'BrowserStack', | ||
| device: 'iPhone X', | ||
| os: 'iOS', | ||
| os_version: '11.0', | ||
| real_mobile: true | ||
| }, | ||
| bs_android_9: { | ||
| base: 'BrowserStack', | ||
| device: 'Google Pixel 3 XL', | ||
| os: 'android', | ||
| os_version: '9.0', | ||
| real_mobile: true | ||
| }, | ||
| win_10_chrome: { | ||
| base: 'BrowserStack', | ||
| browser: 'chrome', | ||
| // Latest Chrome on Windows has WebGL problems: | ||
| // https://github.com/tensorflow/tfjs/issues/2272 | ||
| browser_version: '77.0', | ||
| os: 'Windows', | ||
| os_version: '10' | ||
| }, | ||
| }, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "name": "@tensorflow/tfjs-backend-cpu", | ||
| "version": "0.0.0", | ||
| "description": "Vanilla JavaScript backend for TensorFlow.js", | ||
| "private": false, | ||
| "main": "dist/index.js", | ||
| "jsdelivr": "dist/tf-backend-cpu.min.js", | ||
| "unpkg": "dist/tf-backend-cpu.min.js", | ||
| "types": "dist/index.d.ts", | ||
| "jsnext:main": "dist/tf-backend-cpu.esm.js", | ||
| "module": "dist/tf-backend-cpu.esm.js", | ||
| "engines": { | ||
| "yarn": ">= 1.3.2" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/tensorflow/tfjs.git" | ||
| }, | ||
| "license": "Apache-2.0", | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^11.0.2", | ||
| "@rollup/plugin-node-resolve": "^7.1.1", | ||
| "@rollup/plugin-typescript": "^3.0.0", | ||
| "@tensorflow/tfjs-core": "link:../tfjs-core", | ||
| "@types/jasmine": "~3.0.0", | ||
| "clang-format": "~1.2.4", | ||
| "jasmine": "~3.1.0", | ||
| "jasmine-core": "~3.1.0", | ||
| "karma": "~4.4.1", | ||
| "karma-browserstack-launcher": "~1.4.0", | ||
| "karma-chrome-launcher": "~2.2.0", | ||
| "karma-jasmine": "~1.1.0", | ||
| "karma-typescript": "~4.1.1", | ||
| "npm-run-all": "~4.1.3", | ||
| "rimraf": "~2.6.2", | ||
| "rollup": "~2.3.2", | ||
| "rollup-plugin-terser": "~5.3.0", | ||
| "rollup-plugin-visualizer": "~3.3.2", | ||
| "ts-node": "~7.0.0", | ||
| "tslint": "~5.11.0", | ||
| "tslint-no-circular-imports": "~0.5.0", | ||
| "typescript": "3.5.3", | ||
| "yalc": "~1.0.0-pre.21" | ||
| }, | ||
| "scripts": { | ||
| "build-ci": "tsc", | ||
| "build": "tsc", | ||
| "build-core": "cd ../tfjs-core && yarn && yarn build", | ||
| "build-core-ci": "cd ../tfjs-core && yarn && yarn build-ci", | ||
| "build-npm": "./scripts/build-npm.sh", | ||
| "link-local": "yalc link", | ||
| "publish-local": "rimraf dist/ && yarn build && rollup -c && yalc push", | ||
| "publish-npm": "npm publish", | ||
| "lint": "tslint -p . -t verbose", | ||
| "test": "yarn build-core && karma start", | ||
| "run-browserstack": "karma start --browserstack", | ||
| "test-ci": "./scripts/test-ci.sh" | ||
| }, | ||
| "dependencies": { | ||
| "@types/seedrandom": "2.4.27", | ||
| "seedrandom": "2.4.3" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tensorflow/tfjs-core": "link:../tfjs-core" | ||
| }, | ||
| "browser": { | ||
| "util": false, | ||
| "crypto": false | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need build-core-ci, similar to this: https://github.com/tensorflow/tfjs/blob/master/tfjs-layers/package.json#L44
Because Core's build-ci is slightly different than build: https://github.com/tensorflow/tfjs/blob/master/tfjs-core/package.json#L55-L56