-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
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): Windows 11 23590.1000 and WSL Arch
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version (use command below): 4.13.0
- Browser version: Microsoft Edge 121.0.2220.3
- Tensorflow.js Converter Version: 4.13.0
- test node js version: 18.17.1
Describe the current behavior
Error: Error in transpose: rank of input 2 must match length of perm 0,2,3,1.
at assert (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:7748:15)
at transpose_ (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:23465:5)
at Object.transpose__op [as transpose] (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:12220:29)
at executeOp$9 (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:29599:25)
at F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:30175:50
at F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:4562:22
at Engine.scopedRun (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:4572:23)
at Engine.tidy (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:4561:21)
at tidy (F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:8307:19)
at F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:30175:24
when running rfft and the after transpose in the browser using WebGL:
in
if ($x.dtype === 'complex64') {
return tidy(() => {
let $real = real($x);
let $imag = imag($x);
$real = ENGINE.runKernel(
Transpose, {x: $real} as unknown as NamedTensorMap,
attrs as unknown as NamedAttrMap);
$imag = ENGINE.runKernel(
Transpose, {x: $imag} as unknown as NamedTensorMap,
attrs as unknown as NamedAttrMap);
if (conjugate) {
$imag = neg($imag);
}
return complex($real, $imag);
});
}
in transpose.ts
in @tfjs/core
, although x is a complex64 shape in [1, 13, 64, 33], in let $real = real($x); let $imag = imag($x);
these two functions get a tensor with shape [832,33]. I have tried to find where the issue happens in the code but failed.
Describe the expected behavior
model runs correctly
Standalone code to reproduce the issue
const tf = require('@tensorflow/tfjs');
tf.setBackend('cpu');
tf.enableDebugMode();
tf.tidy(async () => {
const tfmodel = await tf.loadGraphModel(
'http://localhost:3000/FNO2dLite_from_saved_model/model.json',
);
const inputTensor = tf.zeros([1, 64, 64, 5]);
const output = await tfmodel.executeAsync(inputTensor);
});
converted model:
FNO2dLite_from_saved_model.zip
Other info / logs
Node.js cpu backend debug info:
Cast 0.2402999997138977ms 1D 3 3 x: 1D 3
GatherV2 0.8700000047683716ms 1D 3 3 x: 1D 4 indices: 1D 3
Concat 0.3334999978542328ms 1D 4 4 0: 1D 3 1: 1D 1
Prod 0.2727999985218048ms 0D 1 x: 1D 3
Cast 0.017899997532367706ms 1D 1 1 x: 1D 1
GatherV2 0.05390000343322754ms 1D 1 1 x: 1D 4 indices: 1D 1
Prod 0.024800002574920654ms 0D 1 x: 1D 1
Reshape 0.022599995136260986ms 0D 1 x: 0D
Pack 0.3401999995112419ms 1D 2 2 0: 0D 1: 0D
Reshape 0.01990000158548355ms 2D 4096,5 20480 x: 4D 1,64,64,5
BatchMatMul 9.050800003111362ms 2D 4096,13 53248 a: 2D 4096,5 b: 2D 5,13
Reshape 0.014400005340576172ms 4D 1,64,64,13 53248 x: 2D 4096,13
Add 3.8828999996185303ms 4D 1,64,64,13 53248 a: 4D 1,64,64,13 b: 1D 13
StridedSlice 0.8957000002264977ms 0D 1 x: 1D 4
Reshape 0.0076000019907951355ms 0D 1 x: 0D
Pack 0.2149999961256981ms 1D 5 5 0: 0D 1: 0D 2: 0D 3: 0D 4: 0D
Fill 0.15600000321865082ms 5D 1,13,64,25,2 41600
StridedSlice 0.12000000476837158ms 0D 1 x: 1D 4
Reshape 0.00849999487400055ms 0D 1 x: 0D
Pack 0.1729000061750412ms 1D 5 5 0: 0D 1: 0D 2: 0D 3: 0D 4: 0D
Fill 0.03220000118017197ms 5D 1,13,48,8,2 9984
Transpose 9.9307000041008ms 4D 1,13,64,64 53248 x: 4D 1,64,64,13
ZerosLike 0.17249999940395355ms 4D 1,13,64,64 53248 x: 4D 1,13,64,64
Complex 0.0738999992609024ms 4D 1,13,64,64 53248 real: 4D 1,13,64,64 imag: 4D 1,13,64,64
Reshape 0.01759999990463257ms 2D 832,64 53248 x: 4D 1,13,64,64
FFT 2488.2494000047445ms 2D 832,64 53248 input: 2D 832,64
Real 0.10300000011920929ms 2D 832,64 53248 input: 2D 832,64
Imag 0.08919999748468399ms 2D 832,64 53248 input: 2D 832,64
SplitV 67.00439999997616ms 2D 832,33 27456 x: 2D 832,64
SplitV 67.00439999997616ms 2D 832,31 25792 x: 2D 832,64
SplitV 44.32190000265837ms 2D 832,33 27456 x: 2D 832,64
SplitV 44.32190000265837ms 2D 832,31 25792 x: 2D 832,64
Complex 0.12290000170469284ms 2D 832,33 27456 real: 2D 832,33 imag: 2D 832,33
Reshape 0.07990000396966934ms 4D 1,13,64,33 27456 x: 2D 832,33
Real 0.014399997889995575ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Imag 0.006999999284744263ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Transpose 1.7778000012040138ms 4D 1,13,33,64 27456 x: 4D 1,13,64,33
Transpose 9.873700000345707ms 4D 1,13,33,64 27456 x: 4D 1,13,64,33
Complex 0.012400001287460327ms 4D 1,13,33,64 27456 real: 4D 1,13,33,64 imag: 4D 1,13,33,64
FFT 1274.7540999948978ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Real 0.008600004017353058ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Imag 0.0054000020027160645ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Transpose 1.6305999979376793ms 4D 1,13,64,33 27456 x: 4D 1,13,33,64
Transpose 6.2162000015378ms 4D 1,13,64,33 27456 x: 4D 1,13,33,64
Complex 0.011500000953674316ms 4D 1,13,64,33 27456 real: 4D 1,13,64,33 imag: 4D 1,13,64,33
Imag 0.009499996900558472ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Real 0.007199995219707489ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Reshape 0.004900000989437103ms 3D 13,64,33 27456 x: 4D 1,13,64,33
Pack 4.126200005412102ms 5D 1,13,64,33,2 54912 0: 4D 1,13,64,33 1: 4D 1,13,64,33
StridedSlice 2.8289000019431114ms 5D 1,13,8,8,2 1664 x: 5D 1,13,64,33,2
StridedSlice 2.217600002884865ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 23.340500004589558ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
StridedSlice 1.3998000025749207ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 4.960900001227856ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
Add 0.10509999841451645ms 4D 1,13,8,8 832 a: 4D 1,13,8,8 b: 4D 1,13,8,8
StridedSlice 1.5082999989390373ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 4.740699999034405ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
StridedSlice 1.7577999979257584ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 3.125200003385544ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
Sub 0.085999995470047ms 4D 1,13,8,8 832 a: 4D 1,13,8,8 b: 4D 1,13,8,8
Reshape 0.004700005054473877ms 3D 13,8,8 832 x: 4D 1,13,8,8
Pack 1.6943999975919724ms 5D 1,13,8,8,2 1664 0: 4D 1,13,8,8 1: 4D 1,13,8,8
StridedSlice 1.412200003862381ms 5D 1,13,8,8,2 1664 x: 5D 1,13,64,33,2
StridedSlice 0.9057000055909157ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 2.745699994266033ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
StridedSlice 0.6583999991416931ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 2.7393999993801117ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
Add 0.13439999520778656ms 4D 1,13,8,8 832 a: 4D 1,13,8,8 b: 4D 1,13,8,8
StridedSlice 2.185900002717972ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 2.4505999982357025ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
StridedSlice 0.6269000023603439ms 4D 1,13,8,8 832 x: 5D 1,13,8,8,2
Einsum 2.419700004160404ms 4D 1,13,8,8 832 0: 4D 1,13,8,8 1: 4D 13,13,8,8
Sub 0.5145999938249588ms 4D 1,13,8,8 832 a: 4D 1,13,8,8 b: 4D 1,13,8,8
Reshape 0.005199998617172241ms 3D 13,8,8 832 x: 4D 1,13,8,8
Pack 0.042100004851818085ms 5D 1,13,8,8,2 1664 0: 4D 1,13,8,8 1: 4D 1,13,8,8
Concat 0.15489999949932098ms 5D 1,13,64,8,2 13312 0: 5D 1,13,8,8,2 1: 5D 1,13,48,8,2 2: 5D 1,13,8,8,2
Concat 0.13910000026226044ms 5D 1,13,64,33,2 54912 0: 5D 1,13,64,8,2 1: 5D 1,13,64,25,2
StridedSlice 19.49159999936819ms 4D 1,13,64,33 27456 x: 5D 1,13,64,33,2
StridedSlice 20.73200000077486ms 4D 1,13,64,33 27456 x: 5D 1,13,64,33,2
Complex 0.010799996554851532ms 4D 1,13,64,33 27456 real: 4D 1,13,64,33 imag: 4D 1,13,64,33
Real 0.008000001311302185ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Imag 0.006200000643730164ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Transpose 6.112900003790855ms 4D 1,13,33,64 27456 x: 4D 1,13,64,33
Transpose 9.36089999973774ms 4D 1,13,33,64 27456 x: 4D 1,13,64,33
Complex 0.010499998927116394ms 4D 1,13,33,64 27456 real: 4D 1,13,33,64 imag: 4D 1,13,33,64
IFFT 1203.483599998057ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Real 0.007899999618530273ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Imag 0.00469999760389328ms 4D 1,13,33,64 27456 input: 4D 1,13,33,64
Transpose 1.4570000022649765ms 4D 1,13,64,33 27456 x: 4D 1,13,33,64
Transpose 1.4847000017762184ms 4D 1,13,64,33 27456 x: 4D 1,13,33,64
Complex 0.006900005042552948ms 4D 1,13,64,33 27456 real: 4D 1,13,64,33 imag: 4D 1,13,64,33
Real 0.006599999964237213ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Reshape 0.0040000006556510925ms 2D 832,33 27456 x: 4D 1,13,64,33
Imag 0.00509999692440033ms 4D 1,13,64,33 27456 input: 4D 1,13,64,33
Reshape 0.002499997615814209ms 2D 832,33 27456 x: 4D 1,13,64,33
Slice 25.670800000429153ms 2D 832,31 25792 x: 2D 832,33
Reverse 18.266600005328655ms 2D 832,31 25792 x: 2D 832,31
Slice 25.87559999525547ms 2D 832,31 25792 x: 2D 832,33
Reverse 27.317199997603893ms 2D 832,31 25792 x: 2D 832,31
Multiply 1.4156000018119812ms 2D 832,31 25792 a: 2D 832,31 b: 0D
Concat 0.4617999941110611ms 2D 832,64 53248 0: 2D 832,33 1: 2D 832,31
Concat 0.16420000046491623ms 2D 832,64 53248 0: 2D 832,33 1: 2D 832,31
Complex 0.006299994885921478ms 2D 832,64 53248 real: 2D 832,64 imag: 2D 832,64
Reshape 0.0054000020027160645ms 2D 832,64 53248 x: 2D 832,64
IFFT 2520.780900001526ms 2D 832,64 53248 input: 2D 832,64
Real 0.009300000965595245ms 2D 832,64 53248 input: 2D 832,64
F:\GitRepos\CFlowSim\node_modules\@tensorflow\tfjs\node_modules\@tensorflow\tfjs-converter\dist\tf-converter.node.js:7748
throw new Error(typeof msg === 'string' ? msg : msg());
^
Error: Error in transpose: rank of input 2 must match length of perm 0,2,3,1.