-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[TIR, Relay] improve bfloat16 support #10112
Changes from all commits
539e5e0
9fd4dd9
8bf6144
a786001
c959702
7e77f56
8e0766c
12fb7b1
9e32fde
6c29073
07ea8de
5583b86
a526fee
a1a3c31
689eead
09a66f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -302,6 +302,8 @@ inline std::string DType2String(const tvm::DataType dtype) { | |||||
os << "int"; | ||||||
} else if (dtype.is_uint()) { | ||||||
os << "uint"; | ||||||
} else if (dtype.is_bfloat16()) { | ||||||
os << "bfloat"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else if ((*GetPackedFunc("runtime._datatype_get_type_registered"))(dtype.code())) { | ||||||
os << "custom[" | ||||||
<< (*GetPackedFunc("runtime._datatype_get_type_name"))(dtype.code()).operator std::string() | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1177,7 +1177,8 @@ bool NLLLossRel(const Array<Type>& types, int num_inputs, const Attrs& attrs, | |
<< ", weights shape = " << weights->shape); | ||
return false; | ||
} | ||
if (!(predictions->dtype == weights->dtype && predictions->dtype.is_float())) { | ||
if (!(predictions->dtype == weights->dtype && | ||
(predictions->dtype.is_float() || predictions->dtype.is_bfloat16()))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we let There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer this way too, since they are all floating-point datatypes. |
||
reporter->GetDiagCtx().EmitFatal(Diagnostic::Error(reporter->GetSpan()) | ||
<< "NLLLossRel: predictions and weights should" | ||
<< " be of the same floating type."); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do
tir::Cast("bfloat16", {result}, span)
. We usecamel_case
.Can be fixed in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Thanks. I will refine the code style in next PR.