From 12d0fe7c85eb978b1025f69c2639436e047a7ca0 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Fri, 24 Sep 2021 04:25:26 +0000 Subject: [PATCH] Emit a proper error. This assertion was reachable from user code (e.g. !torch.qint8 dtype), which should never be possible for an assertion. Instead, emit a diagnostic. --- .../torch-mlir/lib/Dialect/Torch/IR/TorchTypes.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/external/torch-mlir/lib/Dialect/Torch/IR/TorchTypes.cpp b/external/torch-mlir/lib/Dialect/Torch/IR/TorchTypes.cpp index 33217e556..fc5bfc6dc 100644 --- a/external/torch-mlir/lib/Dialect/Torch/IR/TorchTypes.cpp +++ b/external/torch-mlir/lib/Dialect/Torch/IR/TorchTypes.cpp @@ -263,7 +263,10 @@ static Type convertDtypeToBuiltinElementType(MLIRContext *context, Type dtype) { return IntegerType::get(context, integerType.getWidth(), IntegerType::Signless); } - assert(false && "Unsupported dtype to convert to builtin element type"); + emitError(UnknownLoc::get(context)) + << "unimplemented: conversion of dtype " << dtype + << " to builtin tensor element type"; + return nullptr; } TensorType ValueTensorType::toBuiltinTensor() const { @@ -271,8 +274,10 @@ TensorType ValueTensorType::toBuiltinTensor() const { return nullptr; if (!hasSizes()) return UnrankedTensorType::get(getDtype()); - return RankedTensorType::get( - getSizes(), convertDtypeToBuiltinElementType(getContext(), getDtype())); + Type elementType = convertDtypeToBuiltinElementType(getContext(), getDtype()); + if (!elementType) + return nullptr; + return RankedTensorType::get(getSizes(), elementType); } LogicalResult