[CoreML EP] Add Where and And builders (#28597)
### Summary
Two new ML Program op builders, both produced by transformer
attention-mask
graphs:
- **`Where` → ML Program `select`.** `WhereOpBuilder` gates the X/Y
branches to
float / float16 and requires `cond` to be bool.
- **`And` → ML Program `logical_and`,** via a new `LogicalOpBuilder`.
Inputs must
be bool.
Both are ML-Program-only; `IsOpSupportedImpl` rejects them on the
NeuralNetwork
format so such nodes fall back to CPU.
### Depends on the bool-Cast PR
`And`'s inputs and output are all bool, and a CoreML partition cannot
have bool
I/O, so a meaningful `And` test sandwiches it between `int ↔ bool` casts
(the bool
stays internal). This branch is therefore **stacked on
`coreml-cast-bool`** — the
`cb43b7c75f` commit in this PR is the bool-Cast PR and will drop from
this diff
once that one merges (via `git merge main`). `Where` needs no such
scaffolding:
its `cond` can be a constant initializer and X/Y/output are float.
### Tests (`coreml_basic_test.cc`)
- `Where_MLProgram` — Where with a constant bool `cond` runs on CoreML,
matches CPU.
- `WhereNeuralNetworkNotSupported` — Where falls back on the
NeuralNetwork format.
- `WhereNonFloatBranchesNotSupported` — an int32 Where falls back to
CPU.
- `And_MLProgram` — a `Cast → And → Cast` chain runs fully on CoreML,
matches CPU.
- `AndNeuralNetworkNotSupported` — the chain falls back on the
NeuralNetwork format.
Doc: `coreml_supported_mlprogram_ops.md` lists `And` and `Where`.
### Series — CoreML EP coverage for transformer / diffusion graphs
- #28595 — Support bool Cast in ML Program *(prerequisite)*
- #28596 — Add Sin and Cos unary ops *(independent)*
- **#28597 — Add Where and And builders** *(this PR — depends on
#28595)*
- #28598 — Add GatherND builder *(depends on #28595)*
Together with #28278 (scalar-`Gather`), the series takes BERT / GPT-2 /
ViT /
diffusion-UNet graphs — tiny and full-size — from 2 CoreML partitions to
1, with
zero graph breaks.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>