Skip to content

Conversation

@matthewsloyanARM
Copy link
Contributor

@matthewsloyanARM matthewsloyanARM commented Nov 3, 2025

Description

This sample demonstrates the usage of the VK_ARM_tensors and VK_ARM_data_graph extensions for machine learning inference. These allow you to define a neural network with TOSA operations and then execute inferences using hardware acceleration.

This is the second in a series of samples which introduces graph constants and how to use them in a simple neural network. For example, constants are used in the Convolution 2d operator (commonly used in neural networks). The weights and bias for this operator are fixed values and are stored with the network after training.

The first sample can be found here: #1394

Build & run guide

If you would like to try out this new sample locally, we provide an emulation layer which allows them to run. This can be found here: https://github.com/arm/ai-ml-emulation-layer-for-vulkan. There is also a pre-built Windows package available here: https://www.arm.com/-/media/Files/developer/MLEmulationLayerForVulkan20251107 or you can grab this through our tutorial: https://learn.arm.com/learning-paths/mobile-graphics-and-gaming/vulkan-ml-sample/. This tutorial is for this first sample already merged (simple_tensor_and_data_graph), so it shows you everything needed to try it out. The guide and pre-built is only for Windows though, it does work on Linux, but this will require a manual build from the repository (https://github.com/arm/ai-ml-emulation-layer-for-vulkan). See the build guide for this.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

Signed-off-by: Matthew Sloyan <[email protected]>
Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way this sample builds on the previous one.
Maybe, due to the strong ordering, it might be worth to prepend the directories/projects with a number to get that ordering for the noob as well.
Besides that, just two comments...

Note: I did not try to use the emulation layers. Just by code inspection I would approve this PR, though.

Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great sample and documentation. Works fine for me, I do get several validation errors though:

[error] 222824743 - VUID-vkCreateTensorARM-tensors-09832: vkCreateTensorARM(): tensors feature is not enabled.
The Vulkan spec states: The tensors feature must be enabled (https://docs.vulkan.org/spec/latest/chapters/resources.html#VUID-vkCreateTensorARM-tensors-09832)
[error] 222824743 - VUID-vkCreateTensorARM-tensors-09832: vkCreateTensorARM(): tensors feature is not enabled.
The Vulkan spec states: The tensors feature must be enabled (https://docs.vulkan.org/spec/latest/chapters/resources.html#VUID-vkCreateTensorARM-tensors-09832)
[error] 115483881 - VUID-VkShaderModuleCreateInfo-pCode-08740: vkCreateShaderModule(): SPIR-V Capability GraphARM was declared, but one of the following requirements is required (VkPhysicalDeviceDataGraphFeaturesARM::dataGraph).
The Vulkan spec states: If pCode is a pointer to SPIR-V code, and pCode declares any of the capabilities listed in the SPIR-V Environment appendix, one of the corresponding requirements must be satisfied (https://docs.vulkan.org/spec/latest/chapters/shaders.html#VUID-VkShaderModuleCreateInfo-pCode-08740)
[error] 167135271 - VUID-vkCreateDataGraphPipelinesARM-dataGraph-09760: vkCreateDataGraphPipelinesARM(): dataGraph feature is not enabled.
The Vulkan spec states: The dataGraph feature must be enabled (https://docs.vulkan.org/spec/latest/chapters/VK_ARM_data_graph/graphs.html#VUID-vkCreateDataGraphPipelinesARM-dataGraph-09760)
[error] 1553436542 - VUID-vkGetDataGraphPipelineSessionMemoryRequirementsARM-bindPoint-09784: vkGetDataGraphPipelineSessionMemoryRequirementsARM(): pInfo->bindPoint (VK_DATA_GRAPH_PIPELINE_SESSION_BIND_POINT_TRANSIENT_ARM) not found in session memory requirements.
The Vulkan spec states: The bindPoint member of pInfo must have been returned as part of a VkDataGraphPipelineSessionBindPointRequirementARM whose bindPointType member is VK_DATA_GRAPH_PIPELINE_SESSION_BIND_POINT_TYPE_MEMORY_ARM by a prior call to vkGetDataGraphPipelineSessionMemoryRequirementsARM for the session member of pInfo (https://docs.vulkan.org/spec/latest/chapters/VK_ARM_data_graph/graphs.html#VUID-vkGetDataGraphPipelineSessionMemoryRequirementsARM-bindPoint-09784)

This is with the latest SDK.

 * Fixed possible issue in simple_tensor_and_data sample when running
   with emulation layer.

Signed-off-by: Matthew Sloyan <[email protected]>
@matthewsloyanARM
Copy link
Contributor Author

Thank you both for the review!

@asuessenbach I have addressed the two comments, thank you for the suggestions. Regarding the ordering the samples with numbers I think this is a great idea and it is something we will add. Would it be okay for us to do this in a follow patch when all samples are merge, just so our fork doesn't diverge too much?

@SaschaWillems Glad to hear it, thank you! I haven't seen these on our side, but I will look into it with the latest SDK. The tensor and data graph still isn't fully supported in the public validation layer yet, so this might be the cause.

I have also added the guide to downloading and using the ML Extensions for Vulkan Emulation Layer to the description so other can try it out.

@asuessenbach
Copy link
Contributor

Would it be okay for us to do this in a follow patch when all samples are merge, just so our fork doesn't diverge too much?

Sure, no problem.

@gpx1000
Copy link
Collaborator

gpx1000 commented Jan 9, 2026

These are probably the same VVL feedback items that you're getting from Sascha; but just incase, here it is in Linux:

[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[debug] Building #3 cache object (N3vkb11FramebufferE)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)
[error] -181972258 - VUID-vkCmdDispatch-pDescription-09900: (Warning - This VUID has now been reported 10 times, which is the duplicate_message_limit value, this will be the last time reporting it).
vkCmdDispatch(): the tensor descriptor [VkDescriptorSet 0x310000000031, Set 0, Binding 0, Index 0, variable "input_tensor"] is using tensor VkTensorARM 0x1e000000001e created with usage VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM, which doesn't include VK_TENSOR_USAGE_SHADER_BIT_ARM.
The Vulkan spec states: If a VK_DESCRIPTOR_TYPE_TENSOR_ARM descriptor is accessed as a result of this command, then the underlying VkTensorARM object must have been created with a VkTensorCreateInfoARM::pDescription whose usage member contained VK_TENSOR_USAGE_SHADER_BIT_ARM (https://vulkan.lunarg.com/doc/view/1.4.335.0/linux/antora/spec/latest/chapters/dispatch.html#VUID-vkCmdDispatch-pDescription-09900)

My feedback is the same for this sample that can make the setup easier for Linux folks; everything is already there for it.

I really like both samples, great documentation and explanation along with easy to use features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants