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

Explore adding support for big endian architectures #1460

Open
ghpvnist opened this issue May 3, 2023 · 0 comments
Open

Explore adding support for big endian architectures #1460

ghpvnist opened this issue May 3, 2023 · 0 comments

Comments

@ghpvnist
Copy link
Member

ghpvnist commented May 3, 2023

This was brought up from the discussions on the OpenXLA side. Consider adding support for it in StableHLO as supported endianness for bitcast_convert is currently implementation defined.

ghpvnist added a commit that referenced this issue Jul 6, 2023
Here are the following constraints:
```
(I1) operand is a tensor.
(C1) Let `E` and `E'` be the `operand` and `result` element type,
respectively and `R = rank(operand)`:
* If `num_bits(E')` = `num_bits(E)`, shape(`result`) = shape(`operand`).
* If `num_bits(E')` < `num_bits(E)`:
  * `rank(result) = R+1`.
  * dim(`result`, `i`) = dim(`operand`, `i`) for all `i` in [0, `R`-1].
  * `dim(result, R) = num_bits(E)/num_bits(E')`.
* If `num_bits(E')` > `num_bits(E)`:
  * `rank(result) = R-1`.
  * dim(`result`, `i`) = dim(`operand`, `i`) for all `i` in [0, `R`-1).
  * `dim(operand, R-1) = num_bits(E')/num_bits(E)`.
(C2) Conversion between complex and non-complex types is not permitted.
```

These constraints will be comprehensively covered by the following
tests:

```
I1: a) operand is not a tensor. (Covered by ODS).
C1: a) If `num_bits(E')` = `num_bits(E)`, shape(`result`) != shape(`operand`).
C1: b) If `num_bits(E')` < `num_bits(E)`: `rank(result) != R+1`.
C1: c) If `num_bits(E')` < `num_bits(E)`: dim(`result`, `i`) != dim(`operand`, `i`) for any `i` in [0, `R`-1].
C1: d) If `num_bits(E')` < `num_bits(E)`: `dim(result, R) != num_bits(E)/num_bits(E')`.
C1: e) If `num_bits(E')` > `num_bits(E)`: `rank(result) != R-1`.
C1: f) If `num_bits(E')` > `num_bits(E)`: dim(`result`, `i`) != dim(`operand`, `i`) for all `i` in [0, `R`-1).
C1: g) If `num_bits(E')` > `num_bits(E)`: `dim(operand, R-1) != num_bits(E')/num_bits(E)`.
(C2) Conversion between complex and non-complex types is permitted.
```

If we drop the "Covered by ODS" pieces, this will leave us with the
following test cases:

```
C1a: If `num_bits(E')` = `num_bits(E)`:
     shape(`result`) != shape(`operand`).
C1b: If `num_bits(E')` < `num_bits(E)`:
     `rank(result) != R+1`.
C1c: If `num_bits(E')` < `num_bits(E)`:
     dim(`result`, `i`) != dim(`operand`, `i`) for any `i` in [0, `R`-1].
C1d: If `num_bits(E')` < `num_bits(E)`:
     `dim(result, R) != num_bits(E)/num_bits(E')`.
C1e: If `num_bits(E')` > `num_bits(E)`:
     `rank(result) != R-1`.
C1f: If `num_bits(E')` > `num_bits(E)`:
     dim(`result`, `i`) != dim(`operand`, `i`) for all `i` in [0, `R`-1).
C1g: If `num_bits(E')` > `num_bits(E)`:
     `dim(operand, R-1) != num_bits(E')/num_bits(E)`.
C2: Conversion between complex and non-complex types is permitted.
```

Notes:
* The interpreter assumes little endian representation, and we have
#1460 to address adding support for big endian architectures.

closes #1098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant