-
Notifications
You must be signed in to change notification settings - Fork 950
Add skeleton for the WASM prototype #1863
Conversation
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @nkreeger and @nsthorat)
.vscode/c_cpp_properties.json, line 7 at r2 (raw file):
"includePath": [ "${workspaceFolder}/**", "~/emsdk/fastcomp/emscripten/system/include/**"
note, vscode expects emsdk (emscripten) to be installed in your home dir under ~/emsdk/
tfjs-backend-wasm/.vscode/c_cpp_properties.json, line 7 at r2 (raw file):
"includePath": [ "${workspaceFolder}/src/**", "~/emsdk/fastcomp/emscripten/system/include/**"
note, vscode expects emsdk (emscripten) to be installed in your home dir under ~/emsdk/
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.
Reviewed 1 of 12 files at r1, 22 of 29 files at r2, 5 of 7 files at r3.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @dsmilkov, @nkreeger, and @nsthorat)
.vscode/settings.json, line 12 at r3 (raw file):
}, "tslint.enable": true, "tslint.run": "onType",
is this meant to be removed?
tfjs-backend-wasm/package.json, line 16 at r3 (raw file):
}, "peerDependencies": { "@tensorflow/tfjs-core": "~1.2.5"
update to 1.2.7
tfjs-backend-wasm/src/backend_wasm.ts, line 19 at r3 (raw file):
import {backend_util, DataType, KernelBackend, Rank, registerBackend, ShapeMap, Tensor, util} from '@tensorflow/tfjs-core'; import {BackendValues, TypedArray} from '@tensorflow/tfjs-core/dist/types';
this should be in backend_util now I think as of 1.2.7
tfjs-backend-wasm/src/backend_wasm.ts, line 35 at r3 (raw file):
export class BackendWasm extends KernelBackend { private dataIdNextNumber = 0; private dataIdMap: WeakMap<{}, TensorInfo> = new WeakMap();
can you make {} a named DataId interface for readability and type it here and elsewhere
tfjs-backend-wasm/src/backend_wasm.ts, line 159 at r3 (raw file):
/** Initializes the wasm module and creates the js <--> wasm bridge. */ async function init(): Promise<{wasm: BackendWasmModule}> {
quick comment here about why we return an object wpi;d ne great
tfjs-backend-wasm/src/backend_wasm.ts, line 165 at r3 (raw file):
wasm.tfjs = { registerTensor: wasm.cwrap( 'register_tensor', null,
name null
tfjs-backend-wasm/src/backend_wasm.ts, line 175 at r3 (raw file):
disposeData: wasm.cwrap('dispose_data', null, ['number']), dispose: wasm.cwrap('dispose', null, []), add: wasm.cwrap('add', null, ['number, number, number']),
would be good to name nulls here
tfjs-backend-wasm/src/index_test.ts, line 50 at r3 (raw file):
}); it('element-wise add', async () => {
can we do this with core tests?
tfjs-backend-wasm/src/kernels.cc, line 1 at r3 (raw file):
/* Copyright 2019 Google Inc. All Rights Reserved.
did we want to have a cpp folder?
tfjs-backend-wasm/src/setup_test.ts, line 23 at r3 (raw file):
name: 'test-wasm', backendName: 'wasm', flags: {},
you dont need this line
tfjs-backend-wasm/src/setup_test.ts, line 24 at r3 (raw file):
backendName: 'wasm', flags: {}, isDataSync: true,
remove the comma
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.
Thanks. All comments addressed.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @nkreeger and @nsthorat)
.vscode/settings.json, line 12 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
is this meant to be removed?
Its obsolete now, and vscode highlights it.
tfjs-backend-wasm/package.json, line 16 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
update to 1.2.7
Done.
tfjs-backend-wasm/src/backend_wasm.ts, line 19 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
this should be in backend_util now I think as of 1.2.7
Done.
tfjs-backend-wasm/src/backend_wasm.ts, line 35 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
can you make {} a named DataId interface for readability and type it here and elsewhere
Done.
tfjs-backend-wasm/src/backend_wasm.ts, line 159 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
quick comment here about why we return an object wpi;d ne great
Done.
tfjs-backend-wasm/src/backend_wasm.ts, line 165 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
name null
Done.
tfjs-backend-wasm/src/backend_wasm.ts, line 175 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
would be good to name nulls here
Done.
tfjs-backend-wasm/src/index_test.ts, line 50 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
can we do this with core tests?
Good catch. This was the first test I wrote before I linked core's test, and forgot to remove. We now test against core so this test is obsolete.
tfjs-backend-wasm/src/kernels.cc, line 1 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
did we want to have a cpp folder?
Yes, but I want to move files in a follow-up PR to not risk messing up diffs. We will have src/cpp and src/ts/ (see TODOs in PR description)
tfjs-backend-wasm/src/setup_test.ts, line 23 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
you dont need this line
Done.
tfjs-backend-wasm/src/setup_test.ts, line 24 at r3 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
remove the comma
Done.
For some reason GitHub check didn't get updated, but the Build passed: https://console.cloud.google.com/gcr/builds/0b789b40-d7ee-4e75-b886-709f79c77f4f?project=834911136599 |
Add skeleton code for the WASM backend.
Co-author: @nsthorat
tfjs-backend-wasm
top-level folder (mono-repo style).tslint.json
,settings.json
,package.json
, ...).add()
and test against core unit tests.build.sh
script (will move to Bazel later)Short-term TODOs:
src/cpp/
src/ts/
add
kernel live in its own file so we can drop it in modular builds.This change is