Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception with incompletely specified hierarchical networks #8

Open
mayyxeng opened this issue Mar 21, 2021 · 0 comments
Open

Comments

@mayyxeng
Copy link
Collaborator

mayyxeng commented Mar 21, 2021

namespace hetero.stencil.denoise2d:

actor Filter(uint lower_bound, uint upper_bound, int max_index) int In ==> int Out:

    uint index := 0;
    drop: action In:[t] ==> 
    guard index < lower_bound and index > upper_bound
    do
      if index = max_index - 1 then
        index := 0;
      else
        index := index + 1;
      end
    end

    pass: action In:[t] ==> Out:[t]
    guard index >= lower_bound and index <= upper_bound 
    do 
      index := index + 1;
    end

  end

  actor Splitter() int In ==> int Left, int Right:
    split: action In:[t] ==> Left:[t], Right:[t] end
  end
  actor Denoise2DKernel() 
    int Ref_1_0, 
    int Ref_0_1, 
    int Ref_0_0, 
    int Ref_0_m1, 
    int Ref_m1_0 
    ==> int Out:

    kernel:action 
      Ref_1_0:[t10], 
      Ref_0_1:[t01], 
      Ref_0_0:[t00], 
      Ref_0_m1:[t0m1], 
      Ref_m1_0:[tm10] ==>
      Out:[(t00 - t0m1) * (t00 - t0m1) + 
           (t00 - t01 ) * (t00 - t01 ) + 
           (t00 - tm10) * (t00 - tm10) + 
           (t00 - t10 ) * (t00 - t10 )] 
    end
  end

  network Denoise2D(uint x_dim, uint y_dim) int In ==> int Out:

    entities

      f0 = Filter(
        max_index = x_dim * y_dim, 
        lower_bound = 2 * y_dim + 1, 
        upper_bound = (x_dim - 1) * y_dim + (y_dim - 2));
      f1 = Filter(
        max_index = x_dim * y_dim,
        lower_bound = 1 * y_dim + 2,
        upper_bound = (x_dim - 2) * y_dim + (y_dim - 1)
      );
      f2 = Filter(
        max_index = x_dim * y_dim,
        lower_bound = 1 * y_dim + 1,
        upper_bound = (x_dim - 2) * y_dim + (y_dim - 2)
      );
      f3 = Filter(
        max_index = x_dim * y_dim,
        lower_bound = 1 * y_dim + 0,
        upper_bound = (x_dim - 2) * y_dim + (y_dim - 3)
      );
      f4 = Filter(
        max_index = x_dim * y_dim,
        lower_bound = 0 * y_dim + 1,
        upper_bound = (x_dim - 3) * y_dim + (y_dim - 2)
      );
      
      s0 = Splitter(); s1 = Splitter(); s2 = Splitter(); s3 = Splitter();
      kernel = Denoise2DKernel();

    structure
    
      In --> s0.In;
      s0.Left --> f0.In;
      s0.Right --> s1.In;
      s1.Left --> f1.In;
      s1.Right --> s2.In;
      s2.Left --> f2.In;
      s2.Right --> s3.In;
      s3.Left --> f3.In;
      s3.Right --> f4.In;
      f0.Out --> kernel.Ref_1_0;
      f1.Out --> kernel.Ref_0_1;
      f2.Out --> kernel.Ref_0_0;
      f3.Out --> kernel.Ref_0_m1;
      f4.Out --> kernel.Ref_m1_0;
      **// kernel.Out --> Out; this connection is left out on purpose.**

  end

  network Denoise2D_5x5() int In ==> int Out:
    entities
      stencil_network = Denoise2D(x_dim = 5, y_dim = 5);
    structure

      In --> stencil_network.In;
      stencil_network.Out --> Out;
  end

end

Compiled with

streamblocks vivado-hls --source-path ${CA_SOURCE_PATH}  --target-path ${TARGET_PATH} hetero.stencil.denoise2d.Denoise2D_5x5

Yields

Exception in thread "main" java.util.NoSuchElementException: The node is not part of this tree.
        at se.lth.cs.tycho.phase.TreeShadowImpl.parent(TreeShadowImpl.java:31)
        at se.lth.cs.tycho.attribute.GlobalNames$Implementation.globalName(GlobalNames.java:55)
        at se.lth.cs.tycho.attribute.GlobalNames$Implementation$MultiJ.globalName(GlobalNames$Implementation$MultiJ.java:100)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:50)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:78)
        at se.lth.cs.tycho.ir.IRNode$Transformation.applyChecked(IRNode.java:147)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.applyChecked(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:89)
        at se.lth.cs.tycho.ir.entity.nl.EntityInstanceExpr.transformChildren(EntityInstanceExpr.java:87)
        at se.lth.cs.tycho.ir.entity.nl.EntityInstanceExpr.transformChildren(EntityInstanceExpr.java:21)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.ir.IRNode$Transformation.applyChecked(IRNode.java:147)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.applyChecked(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:89)
        at se.lth.cs.tycho.ir.entity.nl.InstanceDecl.transformChildren(InstanceDecl.java:53)
        at se.lth.cs.tycho.ir.entity.nl.InstanceDecl.transformChildren(InstanceDecl.java:8)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:2)
        at se.lth.cs.tycho.ir.util.ImmutableList.map(ImmutableList.java:35)
        at se.lth.cs.tycho.ir.entity.nl.NlNetwork.transformChildren(NlNetwork.java:73)
        at se.lth.cs.tycho.ir.entity.nl.NlNetwork.transformChildren(NlNetwork.java:17)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.ir.decl.GlobalEntityDecl.transformChildren(GlobalEntityDecl.java:54)
        at se.lth.cs.tycho.ir.decl.GlobalEntityDecl.transformChildren(GlobalEntityDecl.java:8)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:2)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at se.lth.cs.tycho.ir.IRNode$Transformation.mapChecked(IRNode.java:162)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.mapChecked(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:69)
        at se.lth.cs.tycho.ir.NamespaceDecl.transformChildren(NamespaceDecl.java:115)
        at se.lth.cs.tycho.ir.NamespaceDecl.transformChildren(NamespaceDecl.java:11)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.compiler.SourceUnit.transformChildren(SourceUnit.java:29)
        at se.lth.cs.tycho.compiler.SourceUnit.transformChildren(SourceUnit.java:10)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation.apply(ResolveGlobalEntityNamesPhase.java:45)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:80)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.apply(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:2)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at se.lth.cs.tycho.ir.IRNode$Transformation.mapChecked(IRNode.java:162)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase$Transformation$MultiJ.mapChecked(ResolveGlobalEntityNamesPhase$Transformation$MultiJ.java:69)
        at se.lth.cs.tycho.compiler.CompilationTask.transformChildren(CompilationTask.java:98)
        at se.lth.cs.tycho.phase.ResolveGlobalEntityNamesPhase.execute(ResolveGlobalEntityNamesPhase.java:32)
        at se.lth.cs.tycho.compiler.Compiler.compile(Compiler.java:279)
        at se.lth.cs.tycho.compiler.Main.run(Main.java:140)
        at se.lth.cs.tycho.compiler.Main.main(Main.java:23)

Instead of throwing an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant