Skip to content

Conversation

@imaihal
Copy link
Collaborator

@imaihal imaihal commented Mar 15, 2024

This PR replaces PR #2681

This PR enables to run set of ONNX operations in parallel by creating threads using OpenMP dialects. (Previous PR #2681 used async dialect) To realize it, this PR provides new ONNX operations (in onnx-mlir) to create threads; ONNXParallelOP to specify parallel region and ONNXForkOp to specify operations for each thread. OpenMP operations are used in their lowering.

This PR includes new operations and their lowering pass. Rewriting ONNX model for inserting the new operations is not included.

image
  • Input ONNX operations
%Y0, %Y1 = ONNX.Parallel{
   %Y0 = ONNX.Fork () -> tensor<>{
      // ONNX operations

      onnx.yield %Y

   }
   %Y1 = ONNX.Fork () -> tensor<>{
      // ONNX operations

      onnx.yield %Y

  }
   onnx.yield %Y0, %Y1

}
  • After lowering to Krnl
%loop0 = krnl.define_loops
   krnl.parallel(%loop0) : !krnl.loop
   krnl.iterate(%loop0) with (%loop0 -> %arg2 = 0 to 2){
      %idx0 = krnl.get_induction_var_value(%loop0) : (!krnl.loop) -> (index)
      %0 = arith.cmpi eq, %idx0, 0 : index
      scf.if %0 {
         // KrnlIR and ZLowIR for the ONNX operations (Thread 0)
      }
      %1 = arith.cmpi eq, %i, 1 : index
      scf.if  %1 {
         // KrnlIR and ZLowIR for the ONNX operations (Thread 1)
      }
 } // krnl.iterate

imaihal added 21 commits March 26, 2024 07:08
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant