From 8fbf9915b4cb4c92ed7b4c4cda60da573d6e6430 Mon Sep 17 00:00:00 2001 From: mlevesquedion Date: Tue, 6 Feb 2024 09:38:47 -0800 Subject: [PATCH] Add a simple example for execution order (#1992) The text refers to "the example program above", but said example is actually near the top of the file (thousands of lines above). The example is also longer than necessary for the purposes of illustrating execution order. --- docs/spec.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/spec.md b/docs/spec.md index 364635e18f7..b5c1c7bee2a 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -5960,9 +5960,18 @@ The execution order is implementation-defined as long as it is aligned with dataflow, i.e. if ops are executed before their uses. In StableHLO, all side-effecting ops consume one token and produce one token (multiple tokens can be multiplexed into one token via `after_all`), so the execution order of side -effects is also aligned with dataflow. Possible execution orders of the example -program above are `%0` → `%1` → `%2` → `%3` → `%4` → `return` or `%3` → `%0` → -`%1` → `%2` → `%4` → `return`. +effects is also aligned with dataflow. For example, in the below program +there are two possible execution orders: `%0` → `%1` → `%2` → `return` and +`%1` → `%0` → `%2` → `return`. + +```mlir +func.func @main() -> tensor { + %0 = stablehlo.constant dense<1.0> : tensor + %1 = stablehlo.constant dense<2.0> : tensor + %2 = stablehlo.add %0, %1 : tensor + return %2 : tensor +} +``` More formally, a **StableHLO process** is a combination of: 1\) a StableHLO program, 2) operation statuses (not executed yet,