diff --git a/tfjs-backend-wasm/package.json b/tfjs-backend-wasm/package.json index edcb92fbee4..447508ef154 100644 --- a/tfjs-backend-wasm/package.json +++ b/tfjs-backend-wasm/package.json @@ -20,6 +20,7 @@ "publish-local": "rimraf dist/ && yarn build && rollup -c && yalc push", "build-ci": "./scripts/build-ci.sh", "build-npm": "./scripts/build-npm.sh", + "build-fast": "tsc && yarn rollup -c", "build-benchmark": "./scripts/build-benchmark.sh", "buildifier-ci": "./scripts/buildifier-ci.sh", "clean": "rimraf dist/ && bazel clean --expunge", diff --git a/tfjs-backend-wasm/src/base.ts b/tfjs-backend-wasm/src/base.ts new file mode 100644 index 00000000000..4ee49bb947a --- /dev/null +++ b/tfjs-backend-wasm/src/base.ts @@ -0,0 +1,19 @@ +/** + * @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. + * ============================================================================= + */ + +export {BackendWasm, setWasmPath, setWasmPaths} from './backend_wasm'; +export {version as version_wasm} from './version'; diff --git a/tfjs-backend-wasm/src/index.ts b/tfjs-backend-wasm/src/index.ts index 7ef81bcdffa..b33b35c173a 100644 --- a/tfjs-backend-wasm/src/index.ts +++ b/tfjs-backend-wasm/src/index.ts @@ -16,6 +16,4 @@ */ import './register_all_kernels'; - -export {BackendWasm, setWasmPath, setWasmPaths} from './backend_wasm'; -export {version as version_wasm} from './version'; +export * from './base'; diff --git a/tfjs/tools/custom_bundle/cli.ts b/tfjs/tools/custom_bundle/cli.ts index d94fc76ca14..ba7b21700b6 100755 --- a/tfjs/tools/custom_bundle/cli.ts +++ b/tfjs/tools/custom_bundle/cli.ts @@ -81,7 +81,8 @@ function validateArgs(): CustomTFJSBundleConfig { for (const requestedBackend of finalConfig.backends) { if (requestedBackend !== SupportedBackends.cpu && - requestedBackend !== SupportedBackends.webgl) { + requestedBackend !== SupportedBackends.webgl && + requestedBackend !== SupportedBackends.wasm) { bail(`Error: Unsupported backend specified '${requestedBackend}'`); } } diff --git a/tfjs/tools/custom_bundle/esm_module_provider.ts b/tfjs/tools/custom_bundle/esm_module_provider.ts index 24d31cdfc5d..1c7525bee7c 100644 --- a/tfjs/tools/custom_bundle/esm_module_provider.ts +++ b/tfjs/tools/custom_bundle/esm_module_provider.ts @@ -71,6 +71,8 @@ function getBackendPath(backend: SupportedBackend) { return '@tensorflow/tfjs-backend-cpu'; case 'webgl': return '@tensorflow/tfjs-backend-webgl'; + case 'wasm': + return '@tensorflow/tfjs-backend-wasm'; default: throw new Error(`Unsupported backend ${backend}`); } diff --git a/tfjs/tools/custom_bundle/types.ts b/tfjs/tools/custom_bundle/types.ts index 7fb3989b776..a61e8367660 100644 --- a/tfjs/tools/custom_bundle/types.ts +++ b/tfjs/tools/custom_bundle/types.ts @@ -17,7 +17,8 @@ export enum SupportedBackends { cpu = 'cpu', - webgl = 'webgl' + webgl = 'webgl', + wasm = 'wasm' } export type SupportedBackend = keyof typeof SupportedBackends;