From 1f18e7c7260fe1859d7d62f67857f92541673f44 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Tue, 4 Dec 2018 21:14:50 -0800 Subject: [PATCH] Validate matching input shapes in Int8Add operator (#14520) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/14520 Default engine doesn't support broadcast semantics in Int8Add operator. This patch adds a check that shapes are equivalent. Reviewed By: bertmaher Differential Revision: D13250922 fbshipit-source-id: 886ae3951d21e6745e0f162e43a9ac9e837339a0 --- caffe2/operators/quantized/int8_add_op.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/caffe2/operators/quantized/int8_add_op.h b/caffe2/operators/quantized/int8_add_op.h index 56898806bfdb..4f3019500f2b 100644 --- a/caffe2/operators/quantized/int8_add_op.h +++ b/caffe2/operators/quantized/int8_add_op.h @@ -32,6 +32,11 @@ class Int8AddOp final : public Operator { const auto& B = Inputs()[1]->template Get(); auto* Y = Outputs()[0]->template GetMutable(); + CAFFE_ENFORCE_EQ( + A.t.sizes(), + B.t.sizes(), + "inputs must have the same shape (broadcast semantics is not supported)"); + /* * Record quantization parameters for A and B inputs, because if the op is * in-place, we may overwrite these parameters later, when we set