Problem
The TensorFlow/Keras frontend's Softplus converter at coremltools/converters/mil/frontend/tensorflow/ops.py:2149 still emits the native mb.softplus MIL op:
python
def Softplus(context, node):
...
x = mb.softplus(x=x, name=node.name) # native op → fp16/ANE overflow
This is the same native op that overflows in fp16 on Apple Neural Engine at x ≈ 10.4, causing output collapse to 0.
Context
PR #2725 fixes this for the PyTorch frontend by replacing mb.softplus() with the numerically stable decomposition max(x,0) + log(1+exp(-|x|)). The TF frontend was intentionally left out of scope since both original issues (#2687, #2359) originated from PyTorch models.
Proposed Fix
Apply the same _stable_softplus_mil(x) helper to the TF Softplus converter. Alternatively, implement this at the MIL graph-rewrite pass level so all frontends are covered (the DRY fix, as suggested by @ChinChangYang in the PR #2725 review).
Related
Problem
The TensorFlow/Keras frontend's Softplus converter at
coremltools/converters/mil/frontend/tensorflow/ops.py:2149still emits the nativemb.softplusMIL op:python
def Softplus(context, node):
...
x = mb.softplus(x=x, name=node.name) # native op → fp16/ANE overflow
This is the same native op that overflows in fp16 on Apple Neural Engine at
x ≈ 10.4, causing output collapse to 0.Context
PR #2725 fixes this for the PyTorch frontend by replacing
mb.softplus()with the numerically stable decompositionmax(x,0) + log(1+exp(-|x|)). The TF frontend was intentionally left out of scope since both original issues (#2687, #2359) originated from PyTorch models.Proposed Fix
Apply the same
_stable_softplus_mil(x)helper to the TF Softplus converter. Alternatively, implement this at the MIL graph-rewrite pass level so all frontends are covered (the DRY fix, as suggested by @ChinChangYang in the PR #2725 review).Related