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

Constprop through chlo.lgamma #179

Open
vimarsh6739 opened this issue Dec 5, 2024 · 1 comment
Open

Constprop through chlo.lgamma #179

vimarsh6739 opened this issue Dec 5, 2024 · 1 comment

Comments

@vimarsh6739
Copy link
Member

Image

@vimarsh6739 vimarsh6739 changed the title Constprop through stablehlo.lgamma Constprop through chlo.lgamma, Dec 11, 2024
@vimarsh6739 vimarsh6739 changed the title Constprop through chlo.lgamma, Constprop through chlo.lgamma Dec 11, 2024
@vimarsh6739
Copy link
Member Author

Turns out, just calling the lowering to stablehlo isn't enough, we also need to const prop log and log_plus_one.

    %cst = stablehlo.constant dense<0x7F800000> : tensor<f32>
    %cst_0 = stablehlo.constant dense<0.918938517> : tensor<f32>
    %cst_1 = stablehlo.constant dense<2.01490307> : tensor<f32>
    %cst_2 = stablehlo.constant dense<7.500000e+00> : tensor<f32>
    %cst_3 = stablehlo.constant dense<1.000000e+00> : tensor<f32>
    %cst_4 = stablehlo.constant dense<5.000000e-01> : tensor<f32>
    %cst_5 = stablehlo.constant dense<0.000000e+00> : tensor<f32>
    %cst_6 = stablehlo.constant dense<263.38324> : tensor<f32>
    %0 = stablehlo.log_plus_one %cst_5 : tensor<f32>
    %1 = stablehlo.add %cst_1, %0 : tensor<f32>
    %2 = stablehlo.divide %cst_2, %1 : tensor<f32>
    %3 = stablehlo.subtract %cst_4, %2 : tensor<f32>
    %4 = stablehlo.multiply %3, %1 : tensor<f32>
    %5 = stablehlo.log %cst_6 : tensor<f32>
    %6 = stablehlo.add %cst_0, %4 : tensor<f32>
    %7 = stablehlo.add %6, %5 : tensor<f32>
    %8 = stablehlo.abs %cst_3 : tensor<f32>
    %9 = stablehlo.compare  EQ, %8, %cst : (tensor<f32>, tensor<f32>) -> tensor<i1>
    %10 = stablehlo.select %9, %cst, %7 : tensor<i1>, tensor<f32>
    return %10 : tensor<f32>

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

No branches or pull requests

1 participant