Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

How to contribute to Webgl ops? #219

Open
Manojbhat09 opened this issue Aug 28, 2020 · 2 comments
Open

How to contribute to Webgl ops? #219

Manojbhat09 opened this issue Aug 28, 2020 · 2 comments

Comments

@Manojbhat09
Copy link

Please provide a short guide on how to write ops.

@fs-eire
Copy link
Contributor

fs-eire commented Sep 2, 2020

This commit is a good example of adding implementation for a operator on one or more backends.

A rough instruction -

  1. add a new file (if it doesn't exist) under lib/ops/ for the operator, implement an abstract class derived from Operator with member function initialize, checkInputs and checkInputTypes. Operator attributes are usually put here too.

  2. add a new file under lib/backends/webgl/ops/ for the operator, implement a class that extends the abstract class described in (1) and implement interface WebGLOperator as well.

    • function run usually implement as calling WebGLOperatorHelper.run(), unless a custom step is required
    • function createProgramInfo returns the shader and layout
    • function createRunData returns the texture data and uniform binding (if any)
  3. add resolve rules in /lib/backends/webgl/op-resolve-rules.ts for the newly implemented operator.

  4. add standard node test or custom operator test in unittest-whitelist.jsonc.

Let me know if you have further questions

@Manojbhat09
Copy link
Author

Manojbhat09 commented Sep 2, 2020

Hi, @fs-eire Thanks for your response.
I wanted to know how to do tests. There are .pd files I guess generated from TensorFlow.
I was wondering if we can generate the same from Pytorch?
How would that look like?

I did a PR but failed due to tests I think.
#220

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

No branches or pull requests

2 participants