Skip to content

Support for additional Affine dialect operations in Affine loop lowering #182

@guosran

Description

@guosran

Description

Currently in PR #173 , the affine-to-neura lowering pass supports the core loop-based operations (affine.for, affine.load, affine.store, affine.apply) but does not support some other Affine dialect operations.

Currently Supported

  • affine.for - Loop structures with constant bounds
  • affine.load / affine.store - Memory access operations
  • affine.apply - Affine expression computations

Currently Unsupported

Examples include (but not limited to):

  • affine.if - Conditional operations
  • affine.parallel - Parallel loops
  • affine.min / affine.max - Min/max expressions
  • affine.for with dynamic bounds - Loops with runtime-dependent bounds
  • Other advanced affine constructs

Current Behavior

When encountering unsupported operations, the pass fails with legalization errors. For example, with affine.if:

error: failed to legalize operation 'affine.if' that was explicitly marked illegal

The affine operations remain unchanged in the IR, and the pass reports a failure.

A test file test/Conversion/AffineToNeura/unsupported-affine-if.mlir demonstrates one such case.

Example of Unsupported Case

func.func @affine_if_example(%arg0: memref<10xf32>, %N: index) {
  affine.for %i = 0 to 10 {
    affine.if affine_set<(d0) : (d0 - 5 >= 0)>(%i) {
      %val = affine.load %arg0[%i] : memref<10xf32>
    }
  }
  return
}

Reason for Current Limitation

  1. The Neura dataflow model focuses on loop-based computation with static control flow
  2. The current implementation targets the most common loop kernels for CGRA acceleration
  3. Some constructs (like conditionals or dynamic bounds) would require:
    • Predicated operations in the dataflow graph
    • Additional control flow handling in hardware
    • Runtime reconfiguration support

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions