Enforce If condition size == 1 (#18733)

### Description
<!-- Describe your changes. -->

### Motivation and Context
https://github.com/microsoft/onnxruntime/issues/18549
This commit is contained in:
Dmitri Smirnov 2023-12-06 21:04:18 -08:00 committed by GitHub
parent 9479ba525b
commit e603e78627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,7 +248,12 @@ Status If::Compute(OpKernelContext* ctx) const {
auto ctx_internal = static_cast<OpKernelContextInternal*>(ctx);
auto condition = *ctx->Input<Tensor>(0)->Data<bool>();
const auto& condition_tensor = *ctx->Input<Tensor>(0);
ORT_RETURN_IF_NOT(condition_tensor.Shape().Size() == 1,
"If nodes condition input must have exactly one element");
auto condition = *condition_tensor.Data<bool>();
auto attribute = condition ? "then_branch" : "else_branch";
auto* session_state = ctx_internal->SubgraphSessionState(attribute);