Skip to content

Commit c759bce

Browse files
authored
Add documentation about functions to IR.md (onnx#4180)
* Add documentation about functions to IR.md Signed-off-by: Ganesan Ramalingam <grama@microsoft.com> * Fix a type Signed-off-by: Ganesan Ramalingam <grama@microsoft.com> * Address PR feedback Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
1 parent 12c318e commit c759bce

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/IR.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,41 @@ The ‘status’ property indicates whether the syntax, semantics, or presence o
171171

172172
There are two distinct ways to pass information to operators – inputs and attributes. Inputs represent graph inputs or values computed elsewhere in the graph, while attributes are used for values that are constants in the graph. This distinction may be highly relevant to achieving good performance for some implementations, while completely irrelevant to others.
173173

174+
### Functions
175+
176+
A _function_ may be thought of as an operator combined with an implementation of the operator using
177+
other, more primitive, ops, referred to as the _function body_. The function body consists of a
178+
topologically sorted list of nodes that form a graph. Thus, a function combines aspects of both
179+
an operator as well a graph (described below).
180+
181+
Each function contained in a Model (also referred to as a model-local function) serves
182+
as a default or fallback implementation of the corresponding operator. A runtime, however,
183+
may choose to use an alternative implementation of the operator (usually as an optimized kernel).
184+
As such, the unique name of a function is significant as it is implicitly associated with a
185+
semantic specification.
186+
187+
A serialized function (a _FunctionProto_) has the following properties:
188+
189+
|Name|Type|Description|
190+
|---|---|---|
191+
name|string|The name of the function
192+
domain|string|The domain to which this function belongs
193+
doc_string|string|Human-readable documentation for this function. Markdown is allowed.
194+
attribute|string[]|The attribute parameters of the function
195+
input|string[]|The input parameters of the function
196+
output|string[]|The output parameters of the function.
197+
node|Node[]|A list of nodes, forming a partially ordered computation graph. It must be in topological order.
198+
|opset_import|OperatorSetId|A collection of operator set identifiers used by the function implementation.
199+
200+
The name and domain serve to identify the operator uniquely. An opset version is not explicitly
201+
identified in a FunctionProto, but it is implicitly determined by the opset version of the domain
202+
included in the model.
203+
204+
The input, output, and attribute constitute the signature part of the operator. No type information
205+
is explicitly included in the signature.
206+
207+
The opset_import and node fields describe the implementation of the function.
208+
174209
### Graphs
175210

176211
A graph is used to describe a side-effect-free computation (function).

0 commit comments

Comments
 (0)