我从pytorch中导入net到工作区,在把net导入到simulink中的matlab function中,在运行过程中出现如下问题Code generation for custom layer ‘aten__linear0’ for target ‘mkldnn’ is not supported as it returns a dlarra
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 16:18:35
%#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
endclassdef 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 16:18:35
%#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 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 16:18:35
%#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 simulink, neural network MATLAB Answers — New Questions