Unverified Commit 293c21db authored by Spenser Bauman's avatar Spenser Bauman Committed by GitHub
Browse files

[mlir][tosa] Improve lowering of tosa.conv2d (#74143)

The existing lowering of tosa.conv2d emits a separate linalg.generic
operator to add the bias after computing the computation.

This change eliminates that additional step by using the generated
linalg.conv_2d_* operator by using the bias value as the input to the
linalg.conv_2d operation.

Rather than:

    %init = tensor.empty()
    %conv = linalg.conv_2d ins(%A, %B) %outs(%init)

    %init = tensor.empty()
    %bias = linalg.generic ins(%conv, %bias) outs(%init2) {
      // perform add operation
    }

The lowering now produces:

    %init = tensor.empty()
    %bias_expanded = linalg.broadcast ins(%bias) outs(%init)
    %conv = linalg.conv_2d ins(%A, %B) %outs(%bias)

This is the same strategy as
https://github.com/llvm/llvm-project/pull/73049 applied to convolutions.
parent 70815852
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment