intel / intel/mlir-extensions

bf16 not supported in SPIR-V and 'spv' dialect

Open
#167 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
MLIR
Stars
156
Forks
45
Avg merge
4h 14m
Merged PRs (30d)
22

Description

SPIR-V specification and subsequently 'spv' dialect does not support bf16 datatype.

Possible Solutions:

- **Solution 1** [Long term goal]: Make bf16 part of the SPIR-V specification and 'spv' dialect

- **Solution 2 **[Current FIX]: In MLIR toolchain, use bf16 up until 'spv' dialect. Then convert the 'bf16' to 'f16' (just change the type from 'bf16' to 'f16'). Since, both datatype uses 16 bits to represent a number, if the underlying instruction is accessing 'f16' data but accessing it as 'bf16' it should stil work.

**Assumption/Caveat:** This solution would only work if the data converted to 'f16' from 'bf16' is only used by instructions which expects 'bf16'. In other words, those instructions will reinterpret the passed 'f16' data as 'bf16'. We have to enforce this condition. Otherwise, we may incorrectly cast a 'bf16' to 'f16' which can have huge consequences ('bf16' has much higher range of value it can represent, so casting 'bf16' to 'f16' is essentially a lower cast [overflow may occur])

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.