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

Add 'dot' opcode #18

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Add 'dot' opcode #18

merged 1 commit into from
Oct 9, 2024

Conversation

seanmcl
Copy link
Contributor

@seanmcl seanmcl commented Oct 9, 2024

This was missing from the spec, but is parsed by the C++ code.

https://github.com/openxla/stablehlo/blob/46d146850e1b5ae701f493c2d92875c757b85a7c/stablehlo/dialect/StablehloOps.cpp#L557

Tested with

"builtin.module"() ({
  "func.func"() <{function_type = (tensor<28x28xf32>, tensor<784x10xf32>, tensor<1x10xf32>) -> tensor<1x10xf32>, sym_name = "main"}> ({
  ^bb0(%arg0: tensor<28x28xf32>, %arg1: tensor<784x10xf32>, %arg2: tensor<1x10xf32>):
    %0 = "stablehlo.reshape"(%arg0) : (tensor<28x28xf32>) -> tensor<1x784xf32>
    %1 = "stablehlo.dot"(%0, %arg1) : (tensor<1x784xf32>, tensor<784x10xf32>) -> tensor<1x10xf32>
    %2 = "stablehlo.add"(%1, %arg2) : (tensor<1x10xf32>, tensor<1x10xf32>) -> tensor<1x10xf32>
    %3 = "stablehlo.constant"() <{value = dense<0.000000e+00> : tensor<1x10xf32>}> : () -> tensor<1x10xf32>
    %4 = "stablehlo.maximum"(%2, %3) : (tensor<1x10xf32>, tensor<1x10xf32>) -> tensor<1x10xf32>
    "func.return"(%4) : (tensor<1x10xf32>) -> ()
  }) : () -> ()
}) : () -> ()

Will add this as a unit test once I figure out how to do lean unit testing.

@seanmcl seanmcl requested a review from jtristan as a code owner October 9, 2024 17:24
@jtristan jtristan enabled auto-merge (squash) October 9, 2024 18:31
@jtristan jtristan merged commit 038c38c into leanprover:main Oct 9, 2024
1 check passed
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.

2 participants