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

Incorrect quantize output with fp16 scales #392

Open
parthchadha opened this issue Nov 19, 2024 · 1 comment
Open

Incorrect quantize output with fp16 scales #392

parthchadha opened this issue Nov 19, 2024 · 1 comment
Assignees
Labels
mlir-tensorrt Pull request for the mlir-tensorrt project

Comments

@parthchadha
Copy link
Collaborator

module @ins_input_outs_t5_1 {
  func.func @main(%arg0: tensor<2x2xf16> {tensorrt.shape_profile = #tensorrt.shape_profile<min = [2, 2], opt = [2, 2], max = [2, 2]>}) -> tensor<?x?xi8> {
    %cst = stablehlo.constant dense<[1.999510e-01, 9.997550e-02]> : tensor<2xf16>
    %cst_0 = stablehlo.constant dense<-1.280000e+02> : tensor<f16>
    %c = stablehlo.constant dense<2> : tensor<i32>
    %c_1 = stablehlo.constant dense<1> : tensor<1xi32>
    %c_2 = stablehlo.constant dense<2> : tensor<1xi32>
    %c_3 = stablehlo.constant dense<2> : tensor<i32>
    %c_4 = stablehlo.constant dense<2> : tensor<1xi32>
    %0 = stablehlo.concatenate %c_2, %c_4, dim = 0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<2xi32>
    %1 = stablehlo.dynamic_broadcast_in_dim %cst, %0, dims = [0] : (tensor<2xf16>, tensor<2xi32>) -> tensor<2x2xf16>
    %2 = stablehlo.divide %arg0, %1 : tensor<2x2xf16>
    %3 = stablehlo.round_nearest_even %2 : tensor<2x2xf16>
    %cst_5 = stablehlo.constant dense<1.270000e+02> : tensor<f16>
    %4 = stablehlo.clamp %cst_0, %3, %cst_5 : (tensor<f16>, tensor<2x2xf16>, tensor<f16>) -> tensor<2x2xf16>
    %5 = stablehlo.convert %4 : (tensor<2x2xf16>) -> tensor<?x?xi8>
    return %5 : tensor<?x?xi8>
  }
}

the output of ^ network is incorrect when input is:

tensor(
    [[1.0000, 2.0000],
     [3.0000, 4.0000]], 
    dtype=float16, loc=gpu:0, shape=(2, 2))

output:

tensor(
    [[0, 127],
     [0, 0]], 
    dtype=int8, loc=gpu:0, shape=(2, 2))
@parthchadha parthchadha added the mlir-tensorrt Pull request for the mlir-tensorrt project label Nov 19, 2024
@christopherbate
Copy link
Collaborator

Thanks, I will investigate

@christopherbate christopherbate self-assigned this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir-tensorrt Pull request for the mlir-tensorrt project
Projects
None yet
Development

No branches or pull requests

2 participants