Skip to content

Commit 0cb116c

Browse files
authored
chore: bubble attribute error up (#1478)
1 parent 03a0c1c commit 0cb116c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

exla/c_src/exla/exla_mlir.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,7 @@ mlir::Type MLIRModule::ParseType(std::string string) {
121121
}
122122

123123
mlir::Attribute MLIRModule::ParseAttribute(std::string string) {
124-
auto attribute = mlir::parseAttribute(string, context_);
125-
126-
if (attribute == nullptr) {
127-
std::cerr << "Unable to parse MLIR attribute: " << string << std::endl;
128-
exit(1);
129-
}
130-
131-
return attribute;
124+
return mlir::parseAttribute(string, context_);
132125
}
133126

134127
} // namespace exla

exla/c_src/exla/exla_mlir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class MLIRModule {
5858

5959
std::string ToString();
6060

61-
// Note: returns nullptr if the parsing fails
61+
// Note: ParseAttribute and ParseType return nullptr if the parsing fails
6262
mlir::Type ParseType(std::string);
6363
mlir::Attribute ParseAttribute(std::string);
6464

exla/lib/exla/mlir/value.ex

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,21 @@ defmodule EXLA.MLIR.Value do
750750

751751
call_target_name =
752752
case op_type do
753-
{:f, 32} -> "qr_cpu_custom_call_f32"
754-
{:f, 64} -> "qr_cpu_custom_call_f64"
755-
{:f, 16} -> "qr_cpu_custom_call_f16"
756-
{:bf, 16} -> "qr_cpu_custom_call_bf16"
757-
type -> raise "QR decomposition not supported for type #{inspect(type)}"
753+
{:f, 32} ->
754+
"qr_cpu_custom_call_f32"
755+
756+
{:f, 64} ->
757+
"qr_cpu_custom_call_f64"
758+
759+
{:f, 16} ->
760+
"qr_cpu_custom_call_f16"
761+
762+
{:bf, 16} ->
763+
"qr_cpu_custom_call_bf16"
764+
765+
type ->
766+
# Due to matching on EXLA.Defn, we are sure that the device here is always :host
767+
raise "QR decomposition not supported on :host device for type #{inspect(type)}"
758768
end
759769

760770
attributes = [

0 commit comments

Comments
 (0)