peddybeats / hands-down

Slow the spread of COVID-19 by discouraging people from touching their face
6 stars 1 forks source link

Experiment implementing the Conv2D kernel for WASM backend #43

Open peddybeats opened 4 years ago

peddybeats commented 4 years ago

https://github.com/tensorflow/tfjs/issues/2978 has issue description. Looks like we should get to it ourselves.

peddybeats commented 4 years ago

So I was able to write both Conv2dDerInput and Conv2dDerFilter c++ kernels and build a new WASM binary and js library wrapper. I then imported it into our app and confirmed that the kernels were indeed getting registered with the tf js kernel registry (by calling tf.getKernelsForBackend('wasm') and observing that

{kernelName: "Conv2dDerInput", backendName: "wasm", setupFunc: ƒ, kernelFunc: ƒ} with the functions pointing to the right implementation.

However, what I'm somehow missing is the mechanism via which the kernelFunc function is bound to wasmbackend.conv2dDerInput [1] -- at runtime, it is still the placeholder function [2] that is getting called.

I'm pretty stumped because there shouldn't be anything other than [3] that's needed to register a kernel - I'll come back to this tomorrow to see if I can figure out what I'm doing wrong.

[1] https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/ops/conv.ts#L692 [2] https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/backends/backend.ts#L430 [3] https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/kernel_registry.ts#L136

vasanthhr commented 4 years ago

@misterpeddy

When it will be availbel for release ? (I seen you removed back from TO DO list).

{kernelName: "Conv2dDerInput", backendName: "wasm", setupFunc: ƒ, kernelFunc: ƒ}

Berkmann18 commented 4 years ago

@misterpeddy Did you get a chance to make any progress on this?

peddybeats commented 4 years ago

No unfortunately this remained in the same state when I ramped down my work.

Berkmann18 commented 4 years ago

@misterpeddy Are you still as busy as weeks back?

vasanthhr commented 4 years ago

@misterpeddy @Berkmann18

can you please guide me when can you fix this issue? (Really appreciate your support and fix here).

(I would believe this issue happening in tfjs-core.js file).

vasanthhr commented 4 years ago

@misterpeddy / Team,

can you please update on this issues? (Appreciate your support)

peddybeats commented 4 years ago

Hey @vasanthhr I don't believe this issue is fixed (I didn't see the WASM kernel implemented in the last tfjs release). If you have interest in working on it, please use the PR linked as a starting point - though I will warn you, the setup is somewhat difficult (you can't build the tfjs binary without linking in all webgl libs..). I'll be taking an break from my work in about a month and at that point I may have time to look back into this.