Name Strings

SPV_ARM_graph

Contact

To report problems with this extension, please open a new issue at:

Contributors

  • Kevin Petit, Arm Ltd.

Notice

Copyright (c) 2022-2025 Arm Ltd.

Status

Complete.

Version

Last Modified Date

2025-06-18

Revision

1

Dependencies

This extension is written against the SPIR-V Specification, Version 1.6 Revision 2.

This extension requires SPIR-V 1.0.

This extension requires SPV_ARM_tensors.

Overview

This extension adds support for graphs to SPIR-V. Graphs provide a construct to express dataflow computations operating on full resources (only tensors are supported with this extension but graphs could also be used with images). This extension does not define any operations for use within graphs.

Extension Name

To use this extension within a SPIR-V module, the following OpExtension must be present in the module:

OpExtension "SPV_ARM_graph"

Modifications to the SPIR-V Specification, Version 1.6

Terms

Graph: A dataflow graph defined by an OpGraphARM. A graph may consume inputs and produces at least one output.

Graph entry point: An OpGraphARM exposed to the execution environment using a OpGraphEntryPointARM instruction.

Graph Interface Type: An OpTypeTensorARM, OpTypeArray of OpTypeTensorARM, or OpTypeRuntimeArray of OpTypeTensorARM.

Logical Layout of a Module

This extension changes the logical layout of modules as follows:

Add a new section after 11 Function definitions where graph definitions and entry points reside. A graph definition is as follows:

  1. Graph definition, using OpGraphARM.

  2. Graph input values are defined using OpGraphInputARM instructions.

  3. Body instructions.

  4. Graph output values are set using OpGraphSetOutputARM instructions.

  5. Graph end, using OpGraphEndARM.

Validation Rules

Modify Section 2.16.1 Universal Validation Rules:

Change:

"There is at least one OpEntryPoint instruction, unless the Linkage
 capability is being used."

to:

"There is at least one OpEntryPoint instruction, unless the *Linkage*
 or *GraphARM* capability is declared."

Add the following rules:

  • The value of the GraphConstantID operand of OpGraphConstantARM must be unique within a given module, i.e. no two graph constants are allowed to have the same GraphConstantID.

  • If the GraphARM capability is declared, there must be at least one OpGraphEntryPointARM instruction.

  • Two OpGraphInputARM instructions with the same InputIndex must not be part of the same graph definition unless ElementIndex is present in both with different values.

  • Two OpGraphSetOutputARM instructions with the same OutputIndex must not be part of the same graph definition unless ElementIndex is present in both with different values.

  • A graph definition must contain at least one OpGraphSetOutputARM.

  • A graph definition may only contain one of the following instructions:

    • OpGraphInputARM

    • OpGraphSetOutputARM

    • OpExtInst

    • OpCompositeExtract

Capabilities

Modify Section 3.31, "Capability", adding these rows to the Capability table:

Capability Implicitly Declares

4191

GraphARM
Uses graphs.

Instructions

Add the following new instructions:

OpTypeGraphARM

Declare a new graph type.

NumInputs is the number of inputs to the graph. NumInputs is an unsigned 32-bit integer.

InOut N Type is the type <id> for input or output N. Types for the NumInputs inputs must appear first, followed by types for all the outputs. A graph type must have at least one output. All inputs and outputs must all be of Graph Interface Type.

Capability:
GraphARM

4+ variable

4190

Result <id>

Literal
NumInputs

<id>
InOut 0 Type,
InOut 1 Type,
…​

OpGraphConstantARM

Declare a graph constant.

Result Type must be an OpTypeTensorARM.

GraphConstantID is a 32-bit integer.

Capability:
GraphARM

4

4181

<id>
Result Type

Result <id>

Literal
GraphConstantID

OpGraphEntryPointARM

Declare a graph entry point.

Graph must be an OpGraphARM.

Name is the name of the graph entry point being declared. It must be a string literal.

Interface is a list of <id> of global variables that are connected to a graph instantiation. All the graph inputs are listed first, then the graph outputs. All the IDs must come from OpVariable with UniformConstant Storage Class.

Capability:
GraphARM

4+ variable

4182

<id>
Graph

Literal
Name

<id>,<id>,…​
Interface

OpGraphARM

Define a graph.

Result Type must be an OpTypeGraphARM.

Capability:
GraphARM

3

4183

<id>
Result Type

Result <id>

OpGraphInputARM

Define a graph input.

Result Type must be the same as that of the corresponding input, selected by InputIndex, or element of the input, selected by InputIndex and ElementIndex, if ElementIndex is present, in the OpTypeGraphARM of the graph definition this instruction is part of.

InputIndex is the index of the graph input being defined, among all graph inputs. It must be a 32-bit integer.

ElementIndex, when present, is the index into a graph input of tensor array type. It must be a 32-bit integer. If ElementIndex is present, then the type of the graph input selected by InputIndex must be an OpTypeArray or OpTypeRuntimeArray whose Element Type is OpTypeTensorARM.

This instruction must immediately follow an OpGraphARM or OpGraphInputARM instruction.

Capability:
GraphARM

4+

4184

<id>
Result Type

Result <id>

InputIndex <id>

Optional ElementIndex <id>

OpGraphSetOutputARM

Assign the value of a graph output.

Value is the <id> that defines the value to assign to the graph output. The type of Value must be the same as that of the corresponding output, selected by OutputIndex, or element of the output, selected by OutputIndex and ElementIndex, if ElementIndex is present, in the OpTypeGraphARM of the graph definition this instruction is part of.

OutputIndex is the index of the graph output being assigned. It must be a 32-bit integer.

ElementIndex, when present, is the index into a graph output of tensor array type. It must be a 32-bit integer. If ElementIndex is present, then the type of the graph output selected by OutputIndex must be an OpTypeArray or OpTypeRuntimeArray whose Element Type is OpTypeTensorARM.

This instruction must immediately precede an OpGraphEndARM or OpGraphSetOutputARM instruction.

Capability:
GraphARM

4+

4185

<id>
Value

<id>
OutputIndex

Optional <id>
ElementIndex

OpGraphEndARM

Last instruction of a graph.

Capability:
GraphARM

3

4186

Issues

1) What should the type of graphs represent? Should it carry the type of the graph constants used by a graph?

RESOLVED: The type of graphs carries the number of inputs and outputs as well as their type. Inputs and outputs of tensor type may themselves encode the rank and shape of the tensors. The types of the graph constants used is not part of the type of a graph.

2) What types of resources should be supported as graph inputs, outputs and constants?

RESOLVED: This extension only adds support for OpTypeTensorARM and arrays of OpTypeTensorARM.

3) How should graph outputs be handled?

RESOLVED: OpGraphSetOutputARM instructions are used to assign values to individual graph outputs or elements of graph outputs of array type.

Previous drafts have used the following mechanisms:

  • A single per graph OpGraphSetOutputsARM return-style instruction to set all outputs, e.g. OpGraphSetOutputsARM %out1 %out1. This did not extend well to outputs of array type.

  • OpGraphOutputARM instructions to forward-declare the ID for individual outputs. These were required to appear after all OpGraphInputARM instructions and IDs for outputs were then assigned by an intruction as part of the graph body. This former approach was abandonned to allow defining graphs that have one or more outputs directly connected to an input and because forward declarations are generally best avoided.

Revision History

Rev Date Author Changes

1

2025-06-18

Kevin Petit

Initial revision