Skip to content

Vulkan backend fails widening negative integers #1869

Closed

Description

@GMNGeoffrey

When widening integers on the vulkan backend, it appears to treat them as unsigned. It seems to be dependent on the bit widths:

These tests fail:

func @widen_int_i8_i32() attributes { iree.module.export } {
  %input = iree.unfoldable_constant dense<[-42, 0, 42]> : tensor<3xi8>
  %res = "xla_hlo.convert"(%input) : (tensor<3xi8>) -> tensor<3xi32>
  check.expect_eq_const(%res, dense<[-42, 0, 42]> : tensor<3xi32>) : tensor<3xi32>
  return
}

func @widen_int_i16_i32() attributes { iree.module.export } {
  %input = iree.unfoldable_constant dense<[-42, 0, 42]> : tensor<3xi16>
  %res = "xla_hlo.convert"(%input) : (tensor<3xi16>) -> tensor<3xi32>
  check.expect_eq_const(%res, dense<[-42, 0, 42]> : tensor<3xi32>) : tensor<3xi32>
  return
}

[ RUN ] module.widen_int_i8_i32
iree/modules/check/native_module.cc:277: Failure
Failed
Expected equality of these values. Contents does not match.
lhs:
3xi32=214 0 42
rhs:
3xi32=-42 0 42

[ RUN ] module.widen_int_i16_i32
iree/modules/check/native_module.cc:277: Failure
Failed
Expected equality of these values. Contents does not match.
lhs:
3xi32=65494 0 42
rhs:
3xi32=-42 0 42

but this one succeeds

func @widen_int_i32_i64() attributes { iree.module.export } {
  %input = iree.unfoldable_constant dense<[-42, 0, 42]> : tensor<3xi32>
  %res = "xla_hlo.convert"(%input) : (tensor<3xi32>) -> tensor<3xi64>
  check.expect_eq_const(%res, dense<[-42, 0, 42]> : tensor<3xi64>) : tensor<3xi64>
  return
}

It seems telling that https://github.com/google/iree/blob/master/iree/test/e2e/regression/load_i16.mlir uses only positive numbers, whereas https://github.com/google/iree/blob/master/iree/test/e2e/regression/store.mlir uses positive and negative, so I expect this is a known issue somehow :-)

Activity

  1. added
    bug 🐞
    codegen
    on May 11, 2020
  2. hanhanW commented on May 11, 2020

    @hanhanW
    Contributor

    Thanks, it looks like a but we hit last week #1851, I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐞codegen

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions