Skip to content

Commit

Permalink
Add specification for logistic operator (#107)
Browse files Browse the repository at this point in the history
* Add specification for logistic operator

* fix constraints

* rewrite formula to use IEEE-754 operations
  • Loading branch information
ghpvnist authored Sep 12, 2022
1 parent f2fd2ae commit 0b86cad
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/spec_draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ The specification of an op comprises of the following components (in the order
* [cosine](#stablehlocosine)
* [floor](#stablehlofloor)
* [log](#stablehlolog)
* [logistic](#stablehlologistic)
* [max](#stablehlomaximum)
* [min](#stablehlominimum)
* [negate](#stablehlonegate)
Expand Down Expand Up @@ -454,6 +455,49 @@ implementation-defined.

[Back to Ops](#index-of-documented-ops)

## stablehlo.logistic

`stablehlo.logistic(operand) -> result`

### Semantics

Performs element-wise logistic (sigmoid) function on `operand` tensor and
produces a `result` tensor. For floating-point element types, it implements:
$$logistic(x) = division(1, addition(1, exp(-x)))$$
where `addition`, `division`, and `exp` are operations from IEEE-754
specification. For complex element types, computes a complex logistic function,
with corner cases TBD. Numeric precision is implementation-defined.

### Operands

| Name | Type |
|-|-|
| `operand` | tensor of floating-point or complex element types |

### Results

| Name | Type |
|-|-|
| `result` | tensor of floating-point or complex element types |

### Constraints

* (C1) `operand` and `result` have the same type.

### Examples

```mlir
// %operand: [[0.0, 1.0], [2.0, 3.0]]
%result = stablehlo.logistic %operand : tensor<2x2xf32>
// %result: [[0.5, 0.73105858], [0.88079708, 0.95257413]]
// %operand: (1.0, 2.0)
%result = stablehlo.logistic %operand : tensor<complex<f32>>
// %result: (1.02141536, 0.40343871)
```

[Back to Ops](#index-of-documented-ops)

## stablehlo.maximum

`stablehlo.maximum(lhs, rhs) -> result`
Expand Down

0 comments on commit 0b86cad

Please sign in to comment.