Merge pull request #20934 from yongtang:07182018-QuantizedAdd
PiperOrigin-RevId: 205463996
This commit is contained in:
commit
9151e61398
@ -1504,6 +1504,13 @@ REGISTER_OP("QuantizedAdd")
|
||||
.SetIsCommutative()
|
||||
.SetShapeFn([](InferenceContext* c) {
|
||||
TF_RETURN_IF_ERROR(shape_inference::BroadcastBinaryOpShapeFn(c));
|
||||
// min_x, max_x, min_y, max_y should be scalar.
|
||||
ShapeHandle unused;
|
||||
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused));
|
||||
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused));
|
||||
TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused));
|
||||
TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 0, &unused));
|
||||
|
||||
c->set_output(1, c->Scalar());
|
||||
c->set_output(2, c->Scalar());
|
||||
return Status::OK();
|
||||
|
||||
@ -543,4 +543,19 @@ TEST(MathOpsTest, HistogramFixedWidth_ShapeFn) {
|
||||
INFER_OK(op, "[?];[2];[]", "[?]");
|
||||
INFER_OK(op, "[?];[2];?", "[?]");
|
||||
}
|
||||
|
||||
TEST(MathOpsTest, QuantizedAdd_ShapeFn) {
|
||||
ShapeInferenceTestOp op("QuantizedAdd");
|
||||
|
||||
INFER_OK(op, "?;?;?;?;?;?", "?;[];[]");
|
||||
INFER_OK(op, "?;?;[];[];[];[]", "?;[];[]");
|
||||
INFER_OK(op, "[1,2];?;[];[];[];[]", "?;[];[]");
|
||||
INFER_OK(op, "[];[2];[];[];[];[]", "[d1_0];[];[]");
|
||||
|
||||
// Rank checks on input scalars.
|
||||
INFER_ERROR("must be rank 0", op, "?;?;[1];?;?;?");
|
||||
INFER_ERROR("must be rank 0", op, "?;?;?;[2];?;?");
|
||||
INFER_ERROR("must be rank 0", op, "?;?;?;?;[3];?");
|
||||
INFER_ERROR("must be rank 0", op, "?;?;?;?;?;[4]");
|
||||
}
|
||||
} // end namespace tensorflow
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user