Skip to content
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

Question about writing my OPS #907

Open
DavidGOrtega opened this issue Jan 13, 2019 · 4 comments
Open

Question about writing my OPS #907

DavidGOrtega opened this issue Jan 13, 2019 · 4 comments

Comments

@DavidGOrtega
Copy link

DavidGOrtega commented Jan 13, 2019

Hi,

I'm writing my own ops for TF. I have some doubts and maybe someone can explain them to me.
I have read the docs however I had to figure out the rest looking at the code.

There are four backends:

  • fallback (js)
  • webGL (glsl/gles)
  • webassembly (C++)
  • webGPU (C++ alike code)

I'm interested on webGL and webassembly, my doubts are:

  1. Would be amazing if I can write my Layers in any language (js, webGL, webassembly). At the end everything is going to run in the browser so like in other DL frameworks I can use python OPs or GPU/CPU with the penalty of uploading/downloading the data, in webDNN would be very nice if I can just use a layer that runs in vanilla JS. That way operations that are done just once like resize could be reused.
  2. Could be possible to write webGL code in plain JS? I mean, there are many libraries that has those operations I need actually written in glsl. Would be very helpful if I just can call plain JS instead. Is that possible?
  3. During the installation I saw that webassembly backend relies on Eigen. How can I access EIgen?
@milhidaka
Copy link
Member

  1. Currently webdnn does not support mixing backends in one model.

You may divide the model in three graphs

(WebGL part 1) -> (Original part) -> (WebGL part 2)

Then, you can convert two WebGL part separately and write original operator in pure js (not using webdnn). WebDNN can load multiple graphs in one browser session.

  1. Not possible. gpu.js is a solution to run js code on GPU, but combination to webdnn is not straightforward.

  2. see latest guide. https://mil-tokyo.github.io/webdnn/docs/tutorial/setup.html#installing-emscripten-and-eigen

@DavidGOrtega
Copy link
Author

@milhidaka thanks for reply.

My third question is more how do I access eigen in my webassembly OPs. I have properly installed them.
I'm wondering if webDNN exposes the operations in Eigen.

register_elementwise_kernel_webassembly(TransposeOperatorExample, "y = x.transpose(); ")

@milhidaka
Copy link
Member

Eigen is not seamlessly integrated with webdnn's array.

You have to manually wrap raw point as Eigen matrix with specifying shape.

This is the (only) working example:

Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::%%A_MAJOR%%> > a_mat(A, %%LOAD_BUFFER(M)%%, %%LOAD_BUFFER(K)%%);

@DavidGOrtega
Copy link
Author

DavidGOrtega commented Jan 16, 2019

@milhidaka

  1. Not possible. gpu.js is a solution to run js code on GPU, but combination to webdnn is not straightforward.

I'm thinking in creating a replacement of fallback backend replacing all the ops with gpu.js and giving access to the api, that way we would have access to js with gpu right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants