Commit 7a98dd1
authored
Fix sigmoid operator to support boolean tensor inputs (#13515)
This PR fixes the issue where boolean tensors were rejected by the
`sigmoid` operator in ExecuTorch.
Specifically, it removes the rejection check for boolean tensors in
`op_sigmoid.cpp` and adds proper conversion logic:
* `true` → `1.0` → `sigmoid(1.0) ≈ 0.731059`
* `false` → `0.0` → `sigmoid(0.0) = 0.5`
This resolves the failure reported in **#13492**, where a boolean tensor
with shape `(4, 7, 1, 1, 7, 2)` could not be processed by
`sigmoid.default`.
### Changes
* Removed boolean rejection check in `op_sigmoid.cpp`.
* Added boolean-to-float conversion logic (`true -> 1.0`, `false ->
0.0`) before applying sigmoid.
* Added comprehensive boolean tensor tests in `op_sigmoid_test.cpp`.
### Fixes
Fixes #13492
### Test Plan
* Added new unit tests in `op_sigmoid_test.cpp` to validate behavior
with boolean tensors.
* Verified that boolean tensors now produce correct sigmoid outputs
without rejection.1 parent 201beda commit 7a98dd1
2 files changed
+34
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
| |||
89 | 112 | | |
90 | 113 | | |
91 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
92 | 125 | | |
93 | 126 | | |
94 | 127 | | |
| |||
0 commit comments