8000 Multidimensional arrays with partial lookups fail · Issue #442 · gpujs/gpu.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Multidimensional arrays with partial lookups fail #442
Open
@soswow

Description

@soswow

Sorry for poor title. Feel free to modify it if you know how to phrase it.
Here is a simple example:

This will bring trouble:

this.matMult = gpu.createKernel(function (Vw, weights, bias) {
      var a = 0.0;
      var wi = weights[this.thread.x];
      for (var i = 0; i < this.constants.num_inputs; i++) {
        a += Vw[i] * wi[i];
      }
      a += bias[this.thread.x];
      return a;
    }, {
      constants: { num_inputs: this.num_inputs },
      output: [this.out_depth],
    });

But this won't:

this.matMult = gpu.createKernel(function (Vw, weights, bias) {
      var a = 0.0;
      for (var i = 0; i < this.constants.num_inputs; i++) {
        a += Vw[i] * weights[this.thread.x][i];
      }
      a += bias[this.thread.x];

      return a;
    }, {
      constants: { num_inputs: this.num_inputs },
      output: [this.out_depth],
    });

This is what has been generated for the first example:

return function (user_Vw, user_weights, user_bias) {
        const constants_num_inputs = this.constants.num_inputs;
      
      const result = new Float32Array(5);
    
		
    for (let x = 0; x < 5; x++) {
      this.thread.x = x;
      this.thread.y = 0;
      this.thread.z = 0;
      let kernelResult;
      var user_a=0;
var user_wi=user_weights[_this.thread.x];
for (var user_i=0;(user_i<constants_num_inputs);user_i++){
user_a+=(user_Vw[user_i]*user_wi);}

user_a+=user_bias[_this.thread.x];
kernelResult = user_a;
      result[x] = kernelResult;
      
    }

See how user_wi is not indexed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0