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

[WebGL] Failed to compile fragment shader #5293

Closed
Honry opened this issue Jul 6, 2021 · 8 comments · Fixed by #5320
Closed

[WebGL] Failed to compile fragment shader #5293

Honry opened this issue Jul 6, 2021 · 8 comments · Fixed by #5320
Labels
type:bug Something isn't working

Comments

@Honry
Copy link
Contributor

Honry commented Jul 6, 2021

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): All platforms
  • TensorFlow.js version (use command below): tf.js 3.7.0 webgl backend.
  • Browser version: Chrome 93.0.4545.0

Describe the current behavior
WebGL backend throws Failed to compile fragment shader error while using depthwiseConv2d op with specific options. While WebGPU backend doesn't reproduce.

Describe the expected behavior
No error.

Standalone code to reproduce the issue

CodePen: https://codepen.io/honry/pen/wvdMmva

    const input = tf.fill([1, 65, 65, 960], 0);
    const weights = tf.fill([3, 3, 960, 1], 1);
    const result = tf.depthwiseConv2d(input, weights, 1, 'same', 'NHWC', 4);

Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.

Please check error log from https://codepen.io/honry/pen/wvdMmva

@Honry Honry added the type:bug Something isn't working label Jul 6, 2021
@huningxin
Copy link

Thanks @Honry , how about the cpu backend and wasm backend?

@Honry
Copy link
Contributor Author

Honry commented Jul 6, 2021

@huningxin, this issue only reproduce on webgl backend.

@ColorfulCakeChen
Copy link

A similiar situation could be occurred by the following codes (i.e. depthwiseCon2d with ( strides == 2 ) ):

//await tf.setBackend( "cpu" ); // Error not happend in CPU.
await tf.setBackend( "webgl" ); // Error happend in WebGL.

let a = [
  111, 112, 113, 114, 121, 122, 123, 124, 131, 132, 133, 134,
  141, 142, 143, 144, 151, 152, 153, 154, 211, 212, 213, 214,
  221, 222, 223, 224, 231, 232, 233, 234, 241, 242, 243, 244,
  251, 252, 253, 254, 311, 312, 313, 314, 321, 322, 323, 324,
  331, 332, 333, 334, 341, 342, 343, 344, 351, 352, 353, 354];
let shape = [ 3, 5, 4 ];
let x = tf.tensor( a, shape );

let filters = tf.tensor( [ 11, 22, 33, 44 ], [ 1, 1, 4, 1 ] );

// When ( strides == 1 ), No problem.
let c = tf.depthwiseConv2d( x, filters, 1, "valid" );
c.print();
let d = tf.depthwiseConv2d( x, filters, 1, "same" );
d.print();

// When ( strides == 2 ), error: "Failed to compile fragment shader."
let e = tf.depthwiseConv2d( x, filters, 2, "valid" );
e.print();

// When ( strides == 2 ), error: "Failed to compile fragment shader."
let f = tf.depthwiseConv2d( x, filters, 2, "same" );
f.print();

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@Honry
Copy link
Contributor Author

Honry commented Jul 14, 2021

@pyu10055, many thanks for fixing this issue! The compile error had been fixed, but the computed result looks wrong.

Here's a simple test, I just compared the first value of the output buffer, which is obviously different from result from wasm and cpu backends.

https://codepen.io/honry/pen/wvdMmva

@Honry
Copy link
Contributor Author

Honry commented Jul 23, 2021

@pyu10055, friendly ping. :) Should I create a separate issue for incorrect computational result?

@rthadur
Copy link
Contributor

rthadur commented Jul 23, 2021

@Honry please open a new issue. Thank you

@Honry
Copy link
Contributor Author

Honry commented Jul 26, 2021

Thanks @rthadur, I've created a new issue at #5378.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants