Skip to content

[Dialect] [OneDNNGraph] Add onednn_graph ops for llama2 mlp #92

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

Merged
merged 10 commits into from
May 29, 2024

Conversation

LongshengDu
Copy link
Contributor

@LongshengDu LongshengDu commented May 21, 2024

Add llama2 mlp ops: sigmoid, type_cast, pow, mul, sub, div, reduce_sum, reduce_mean

@LongshengDu LongshengDu added the WIP work in progress label May 21, 2024
@LongshengDu LongshengDu force-pushed the longsheng/add_onednn_ops branch from 21992a7 to 0781b4f Compare May 27, 2024 12:15
@LongshengDu LongshengDu removed the WIP work in progress label May 28, 2024
[SameOperandsAndResultElementType, InferTensorTypeAdaptor]> {
let summary = [{
MatMul operation computes the product of two tensors with optional bias addition.
}];
let description = [{
`https://oneapi-src.github.io/oneDNN/dev_guide_op_matmul.html`
}];

let arguments = (ins OneDNNGraph_FloatTensor:$input_a,
OneDNNGraph_FloatTensor:$input_b,
Optional<OneDNNGraph_LogicalTensor>:$bias,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional bias here shall also be OneDNNGraph_FloatTensor

@xurui1995
Copy link
Contributor

can you add some new ops in the test of onednn-graph-to-linalg.mlir?

@yifeizh2
Copy link
Contributor

https://github.com/intel/graph-compiler/blob/main/lib/gc/Dialect/OneDNNGraph/OneDNNGraphOps.cpp#L48
The batch dimensions of oneDNN Graph Matmul does not necessarily need to be equal. They can be broadcastable.

@LongshengDu
Copy link
Contributor Author

can you add some new ops in the test of onednn-graph-to-linalg.mlir?

OP Lowering PR is WIP


// CHECK-LABEL: @relu
func.func @relu(%arg0: tensor<128x512xbf16>) -> tensor<128x512xbf16> {
// CHECK: onednn_graph.relu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these at all? What do they test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for basic format, attrs, auto verify and canonicalize, etc. Similar to llvm-project/mlir/test/Dialect/Linalg/named-ops.mlir

@LongshengDu
Copy link
Contributor Author

https://github.com/intel/graph-compiler/blob/main/lib/gc/Dialect/OneDNNGraph/OneDNNGraphOps.cpp#L48 The batch dimensions of oneDNN Graph Matmul does not necessarily need to be equal. They can be broadcastable.

Noted, added a TODO. Will fix this after issues resolved in lowering pass

Copy link
Contributor

@xurui1995 xurui1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LongshengDu LongshengDu merged commit 8eeda34 into main May 29, 2024
4 checks passed
@LongshengDu LongshengDu deleted the longsheng/add_onednn_ops branch May 29, 2024 08:52
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.

5 participants