在matlab function中导​入net,但是出现了​以下问题,尝试过6.​3和8.1版本的Mi​nG64,但是一直报​错。Deep learning code generation using MinGW64 Compiler (C++) toolchain is not supported for mkldnn target.

21 views (last 30 days)

Accepted Answer

Angelo Yeo
Angelo Yeo on 20 May 2024
MinGW is not supported for this workflow yet. Would you install the Visual Studio 2022 and use its compiler? See the webpage below for instruction
Next, in the command window, enter "mex -setup c++" command and select Visual Studio compiler for C++ Compilation, and see if the workflow works.
For more information, see the doc below.
  11 Comments
Angelo Yeo
Angelo Yeo on 22 May 2024
Edited: Angelo Yeo on 22 May 2024
Hi @guiyang, thank you so much for sharing the model. I will share it with dev team and report the issue. Also, it's great to know that you had some progress.
The new issue is about checking validity of custom layer. The issue is described in the docs below.
There must be multiple classes generated for the imported model like "aten_linear0.m". Would you add the %#codegen pragma for all the custom layer classes and see if you can fix the issue?
guiyang
guiyang on 24 May 2024
我加入了%#codegen,它显示了具体错误,错误如下Code generation for custom layer 'aten__linear0' for target 'mkldnn' is not supported as it returns a dlarray object with data format 'UU' as output 'out'.我尝试了各种方法但是并没有有效解决。
classdef aten__linear0 < nnet.layer.Layer & nnet.layer.Formattable & ...
nnet.layer.AutogeneratedFromPyTorch & nnet.layer.Acceleratable
%aten__linear0 Auto-generated custom layer
% Auto-generated by MATLAB on 2024-05-24 10:16:56
%#codegen
properties (Learnable)
% Networks (type dlnetwork)
end
properties
% Non-Trainable Parameters
end
properties (Learnable)
% Trainable Parameters
Param_weight
Param_bias
end
methods
function obj = aten__linear0(Name, Type, InputNames, OutputNames)
obj.Name = Name;
obj.Type = Type;
obj.NumInputs = 1;
obj.NumOutputs = 1;
obj.InputNames = InputNames;
obj.OutputNames = OutputNames;
end
function [linear_9] = predict(obj,linear_x_1)
%Validates that the input has the correct format and permutes its dimensions into the reverse of the original PyTorch format.
model_tt.ops.validateInput(linear_x_1,2);
[linear_x_1, linear_x_1_format] = model_tt.ops.permuteInputToReversePyTorch(linear_x_1, 2);
[linear_x_1] = struct('value', linear_x_1, 'rank', int64(2));
[linear_9] = tracedPyTorchFunction(obj,linear_x_1,false,"predict");
%Permute U-labelled output to forward PyTorch dimension ordering
if(any(dims(linear_9.value) == 'U'))
linear_9 = permute(linear_9.value, fliplr(1:max(2,linear_9.rank)));
end
end
function [linear_9] = forward(obj,linear_x_1)
%Validates that the input has the correct format and permutes its dimensions into the reverse of the original PyTorch format.
model_tt.ops.validateInput(linear_x_1,2);
[linear_x_1, linear_x_1_format] = model_tt.ops.permuteInputToReversePyTorch(linear_x_1, 2);
[linear_x_1] = struct('value', linear_x_1, 'rank', int64(2));
[linear_9] = tracedPyTorchFunction(obj,linear_x_1,true,"forward");
%Permute U-labelled output to forward PyTorch dimension ordering
if(any(dims(linear_9.value) == 'U'))
linear_9 = permute(linear_9.value, fliplr(1:max(2,linear_9.rank)));
end
end
function [linear_9] = tracedPyTorchFunction(obj,linear_x_1,isForward,predict)
linear_weight_1 = obj.Param_weight;
[linear_weight_1] = struct('value', dlarray(linear_weight_1,'UU'), 'rank', 2);
linear_bias_1 = obj.Param_bias;
[linear_bias_1] = struct('value', dlarray(linear_bias_1,'UU'), 'rank', 1);
[linear_9] = model_tt.ops.pyLinear(linear_x_1, linear_weight_1, linear_bias_1);
end
end
end

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!