qjia7 / tfjs-core

WebGL-accelerated ML // linear algebra // automatic differentiation for JavaScript.
https://js.tensorflow.org
Apache License 2.0
2 stars 1 forks source link

render pipeline + cs pipeline makes result incorrect #17

Open GreyZzzzzzXh opened 5 years ago

GreyZzzzzzXh commented 5 years ago

TEST ENV: Windows10, Chrome Canary(Version 77.0.3819.0), D3D11 backend.

CASE:

const inputShape = [1,3,3,1]; /*Ni,Hi,Wi,Ci*/
const filterShape = [2,2,1,1]; /*Hk,Wk,Ci,Co*/
const stride = 1;
const pad = 'valid';

const x = tf.tensor4d([1,2,3,4,5,6,7,8,9], inputShape);
const w = tf.tensor4d([1,1,1,1], filterShape);

const result = tf.conv2d(x, w, stride, pad);
result.print(1);

this case will use 3 ops:

if changing im2col or packTensor to render pipeline, result will be wrong.

wrong result:

Tensor
  dtype: float32
  rank: 4
  shape: [1,2,2,1]
  values:
    [[[[0],
       [0]],

      [[0],
       [0]]]]
GreyZzzzzzXh commented 5 years ago

TEST ENV: Windows10, Chrome Canary(Version 77.0.3819.0), D3D11 backend.

CASE: tfjs-examples, mobilenet

if changing im2col to render pipeline, result will be wrong.

wrong result: image