praeclarum / webgpu-torch

Tensor computation with WebGPU acceleration
MIT License
576 stars 15 forks source link

`Conv2d` not yet implemented #5

Closed koudonojinchuu closed 1 year ago

koudonojinchuu commented 1 year ago

Hi, first of all thanks a lot for this enthusiasting project!

So, I tried to write a small Deno (I'm using v1.31.3 with WebGPU support) script which uses some sample code I found in your sources:

import torch from "webgpu-torch";

if (!await torch.initWebGPUAsync()) {
    console.warn(`WebGPU is not supported.`);
}

class Model extends torch.nn.Module {
  conv1;
  avgPool1;
  avgPool2;
  conv2;

  constructor() {
      super();
      this.conv1 = torch.nn.Conv2d(1, 20, 5);
      this.avgPool1 = new torch.nn.AvgPooling2d(2, 2)
      this.conv2 = torch.nn.Conv2d(20, 20, 5);
  }

  forward(input) {
      let output = this.conv1.forward(input);
      output = output.relu();
      output = this.conv2.forward(output);
      output = output.relu();
      output = this.avgPool1.forward(output);

      return output;
  }

}

let model = new Model();
model.forward();

But the problem is that it returns the error:

error: Uncaught TypeError: this.conv1.forward is not a function
      let output = this.conv1.forward(input);

I'm trying to understand why the instantiation of Conv2d wouldn't have the forward method...

I would appreciate any hint or any info that could push me towards the right direction!

koudonojinchuu commented 1 year ago

Oh, I think I understand: Conv2d is not yet implemented, is it?