From 7e73783c6fefb592a112859781cf662bfb0f408d Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Thu, 11 Apr 2019 19:38:21 -0700 Subject: [PATCH] Fix promoteTypes for QInt types (#19182) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/19182 This is a bug discovered by zafartahirov, right now if one of the tensor is QInt type we'll return undefined, but actually we want to allow ops that accepts Tensors of the same QInt type to work. Reviewed By: zafartahirov Differential Revision: D14909172 fbshipit-source-id: 492fd6403da8c56e180efe9d632a3b7fc879aecf --- c10/core/ScalarType.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/c10/core/ScalarType.h b/c10/core/ScalarType.h index 99e7975..b34ed42 100644 --- a/c10/core/ScalarType.h +++ b/c10/core/ScalarType.h @@ -246,6 +246,11 @@ static inline ScalarType promoteTypes(ScalarType a, ScalarType b) { "promoteTypes with complex numbers is not handled yet; figure out what the correct rules should be"); } + // For QInt types, we only allow exact match + if (isQIntType(a) && a == b) { + return a; + } + if (isQIntType(a) || isQIntType(b)) { AT_ERROR( "promoteTypes with quantized numbers is not handled yet; figure out what the correct rules should be"); -- 2.7.4