Codegen failed to infer output size of built-in function, ??? Dimension 1 is fixed on the left-hand side but varies on the right ([1 x :?] ~= [:? x :?])
조회 수: 1 (최근 30일)
이전 댓글 표시
I tried to codegen a large file containing downsample(), below is a simplified one. For some reason, I have to specify the output size. However, coder failed to infer the size of output of dowmsample().
function a = zzz_tmp0329_33(n)%#codegen
coder.varsize('a', [1 Inf], [0 1] );
b = [1,2,3,4];
a = downsample(b, n);
end
Below is the script to run codegen
% ZZZ_TMP0329_33_SCRIPT Generate static library zzz_tmp0329_33 from
% zzz_tmp0329_33.
%
% Script generated from project 'zzz_tmp0329_33.prj' on 14-Sep-2022.
%
% See also CODER, CODER.CONFIG, CODER.TYPEOF, CODEGEN.
%% Create configuration object of class 'coder.CodeConfig'.
cfg = coder.config('lib','ecoder',false);
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
cfg.GenCodeOnly = true;
%% Define argument types for entry-point 'zzz_tmp0329_33'.
ARGS = cell(1,1);
ARGS{1} = cell(1,1);
ARGS{1}{1} = coder.typeof(0);
%% Invoke MATLAB Coder.
codegen -config cfg zzz_tmp0329_33 -args ARGS{1}
The error says ??? Dimension 1 is fixed on the left-hand side but varies on the right ([1 x :?] ~= [:? x :?]). Why would it say downsample a vector leads to size [:? x :?] ?
Do you know why coder cannot determine the size of output from downsample()?
댓글 수: 0
답변 (1개)
David Fink
2022년 9월 14일
Thank you for reporting this!
There have been some changes to downsample - try a recent version of MATLAB - R2021b or newer, where this is fixed.
댓글 수: 2
David Fink
2022년 9월 15일
In R2020a, you could reshape the output of downsample to the expected 1x?:
a = reshape(downsample(b, n), 1, []);
which (similar to upgrading to R2021b or newer) would allow you to remove the coder.varsize declaration.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!