Add type inference for BroadcastGradientArgs (#5501)

* Add type inference for BroadcastGradientArgs

This change enables the ONNX shape and type inference to work on a function body containing a BroadcastGradientArgs op. Without this change, the dummy inference function is used, and no types are inferred for the output here:

531e6dd459/onnx/shape_inference/implementation.cc (L467-L469)

* Handle optional outputs.
This commit is contained in:
Derek Murray 2020-10-15 16:11:24 -07:00 committed by GitHub
parent 7da7e07909
commit 88f6523baf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1433,7 +1433,13 @@ Example 4:
.TypeConstraint(
"T",
{"tensor(int64)"},
"Constrain input and output types to 64-bit integer.");
"Constrain input and output types to 64-bit integer.")
.TypeAndShapeInferenceFunction([](ONNX_NAMESPACE::InferenceContext& ctx) {
// NOTE: Both outputs are optional.
for (size_t i = 0; i < ctx.getNumOutputs(); ++i) {
updateOutputElemType(ctx, i, ONNX_NAMESPACE::TensorProto::INT64);
}
});
ONNX_CONTRIB_OPERATOR_SCHEMA(GistBinarizeEncoder)
.SetDomain(kMSDomain)