Skip to content

Commit

Permalink
Improve vectorization of bindings (#10888)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Jun 23, 2023
1 parent 89ecd3f commit f41a266
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -1002,6 +1002,7 @@ protected
Type binding_ty;
list<tuple<InstNode, Expression>> iters;
ComponentRef prefix_cr;
Integer dim_count;
algorithm
if not Binding.isBound(binding) then
return;
Expand All @@ -1021,7 +1022,13 @@ algorithm
dims := List.flatten(list(Type.arrayDims(InstNode.getType(n)) for n in nodes));
binding_ty := Type.liftArrayLeftList(binding_ty, dims);

dims := List.stripN(dims, Expression.dimensionCount(exp));
dim_count := Expression.dimensionCount(exp) - Type.dimensionCount(binding_ty);

if dim_count <= 0 then
return;
end if;

dims := List.lastN(dims, dim_count);

if not listEmpty(dims) then
if Expression.isLiteral(exp) then
Expand Down
Expand Up @@ -18,6 +18,6 @@ end VectorizeBindings1;
// class VectorizeBindings1
// parameter Real p = 2.0;
// parameter Real[2, 3] m.q = fill(2.0, 2, 3);
// parameter Real[2, 3] m.p = array(array(2.0 * p for $m2 in 1:3) for $m1 in 1:2);
// parameter Real[2, 3] m.p = fill(2.0 * p, 2, 3);
// end VectorizeBindings1;
// endResult

0 comments on commit f41a266

Please sign in to comment.