Skip to content

Commit

Permalink
extend design for fpmath mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wzt1997 committed Aug 27, 2024
1 parent 83217a2 commit d633cf7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions rfcs/20240808-graph-api-int-compression-for-sdpa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,26 @@ the design of floating point math mode also helps to maintain a consistent API
semantics between graph API and primitive API.
Currently, oneDNN Graph API supports setting floating-point math mode during the
construction of graph object, which will affect the whole graph. The API is
like:
construction of graph object, which will affect the whole graph.
As primitive API has supported a second argument for enforcing an integral
primitive to comply with the floating-point math mode, oneDNN Graph API need to
accommodate to the change. The new API will be like:
```cpp
/// @param mode Floating-point math mode.
/// @param apply_to_int Use of floating-point arithmetic for integer primitives.
void set_fpmath_mode(fpmath_mode mode, bool apply_to_int = false);
```

Users can use the new API like:

```cpp
using namespace dnnl::graph;

// Specify math_mode while constructing the graph
graph g(kind, math_mode);
graph g(kind);
g.set_fpmath_mode( math_mode, /*apply_to_int=*/true);

op foo(id, kind, "foo"); g.add_op(foo);
op bar(id, kind, "bar"); g.add_op(bar);
g.finalize();
Expand All @@ -297,6 +309,9 @@ cp0.execute(…);
cp1.execute(…);
```
User can still set graph-level fpmath mode through graph constructor, and only
one method is allowed for a graph.
#### Alternative option
Considering the fact that the framework users can create different graphs if
Expand Down

0 comments on commit d633cf7

Please sign in to comment.