Skip to content

The output of tf.depthwiseConv2d operation on the tensorflow backend is inconsistent with the output on the CPU backend #8394

Open
@liliquan0118

Description

@liliquan0118

Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04; MacOs 13.3 (22E252)
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link): script link
  • TensorFlow.js version (use command below): 4.2.0
  • Browser version: Chrome Version 128.0.6613.86 (Official Build) (arm64)
  • Tensorflow.js Converter Version:

Describe the current behavior
Given the specific input and the operator tf.depthwiseConv2d, the output of the backend WASM is inconsistent with the backend CPU and WebGL. The outputs are shown in the following image:

Output:
image

Describe the expected behavior
The outputs are the same across all backends.

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.

var input= [[[-421053263.4441943,114102539.68793297,147115217.79530478,-1530087849.7451189,-663738902.7531364,452391372.37027836,1659629120.0815144],[301594579.6472912,-356164044.1506145,266439913.60519361,-1450644069.9783628,-1540888314.666401,164559112.6888523,-2123034789.790392],[284140080.5244317,914319439.3676262,80424772.68100452,-1166697453.9429698,2043308685.9588656,-72941199.77395558,-389582890.48835564],[-2081367517.900015,-2124138282.3567963,-284782884.7234247,-558855070.0987334,-1735264684.880061,766889942.8037453,-1172639968.9652958],[178087994.30779266,1066904605.6317039,-755009327.7292852,1887896634.9931417,508342392.17434216,-1234424142.1151886,741919239.8420424],[-732810339.6071801,1788081189.116138,-1519979207.9841657,1683250262.475779,-625613512.6526172,-1939796634.0895288,969255901.6846681],[-1921344653.3677802,2101627538.9832788,-624928937.7168512,1939431079.3239546,-764361737.3189139,323368037.2242322,-1548042810.184077],[1183883500.2959166,-286358760.32818365,-593424917.9777486,1373455153.9422479,-910684498.624665,376132635.9368377,1802049128.6150503],[1993186070.696113,-1590620038.0907335,363237508.53740025,-332181582.559515,1807423011.5232744,1607975600.000033,-162922875.6336038]]]
    var filter= tf.fill([1,7,7,3],-203742908.76665998)
    async function depthwiseConv2d(backend){
        await tf.setBackend(backend);
        await tf.ready() 

        const result = await tf.depthwiseConv2d(input,filter,10,0,"NHWC",1,"ceil");
        await console.log("the result of ", tf.getBackend(), "is:\n");
        await result.print();
    }
    async function test() {

        await depthwiseConv2d("cpu");
        await depthwiseConv2d("tensorflow");
    }
    
    test();

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions