Back to All
Developer Blog

Deploy AI Models on Snapdragon X Elite with Qualcomm AI Hub

Sign up for Developer monthly newsletter-image

Sign up for Developer monthly newsletter

Join thousands of developers around the globe who receive latest news and updates from our monthly curated newsletter.

Sign up
Come for support, stay for the community-image

Come for support, stay for the community

Get support from experts, connect with like-minded developers, and access exclusive virtual events.

Join Developer Discord

Using Qualcomm AI Hub, in just minutes, developers can convert any model to an ONNX model that can run on the NPUs (neural processing units) in Snapdragon® platforms.

You can either leverage a model from our collection, Qualcomm AI Hub Models, that we’ve tested across various devices or, if you already have a pretrained model for your use case, you can bring your own model (BYOM) and leverage the Qualcomm AI Hub Platform.

The Qualcomm AI Hub optimizes and compiles your model, providing a downloadable target model to bundle into your app and run on your desired edge device. Through Qualcomm AI Hub you can test your model ahead of deploying by running inference on real devices to see key performance metrics (latency, memory, compute unit) and confirm numerical accuracy with your dataset.

1. Convert your model to ONNX Runtime

Choose a Pre-Optimized Model

Browse and download 175+ popular pre-optimized ONNX models from Qualcomm AI Hub Models, or export from PyTorch to ONNX yourself via Qualcomm AI Hub Models GitHub Repository:

# Install AI Hub Models
pip install qai_hub_models[whisper_base_en]

# Compile Whisper Base to ONNX and profile on a Snapdragon X Elite laptop
python -m qai_hub_models.models.whisper_base_en.export --target-runtime onnx --device "Snapdragon X Elite CRD”

Bring Your Own Model
Use Qualcomm AI Hub API to convert your own PyTorch model to ONNX Runtime.

1. Install requirements:

pip install torch torchvision numpy qai-hub

2. Export your model:

import numpy as np
import torch
import torchvision

import qai_hub as hub

# Using pre-trained MobileNet
torch_model = torchvision.models.mobilenet_v2(pretrained=True)
torch_model.eval()

# Trace model
model_input_spec = {"image": ((1, 3, 224, 224), "float32")}
sample_inputs = [torch.rand(model_input_spec["image"][0], dtype=torch.float32)]
traced_model = torch.jit.trace(torch_model.to("cpu"), sample_inputs)

# Export trace to ONNX
compile_job = hub.submit_compile_job(
    model=traced_model,
    device=hub.Device("Snapdragon X Elite CRD"),
    input_specs=model_input_spec,
    options="--target_runtime onnx --output_names classes"
)

# Download compiled model to disk
compile_job.get_target_model().download("mobilenet_v2")

# Profile model on a cloud-hosted Snapdragon X Elite Device
profile_job = hub.submit_profile_job(
    model=compile_job.get_target_model(),
    device=hub.Device("Snapdragon X Elite CRD"),
)

# Run inference on model on a cloud-hosted Snapdragon X Elite Device
inference_job = hub.submit_inference_job(
    model=compile_job.get_target_model(),
    device=hub.Device("Snapdragon X Elite CRD"),
    inputs={"image": [np.asarray(sample_inputs[0])]}
)

# Download on-device inference outputs
# {“classes”: [output_numpy_array]}
outputs = inference_job.download_output_data()

2. Execute an ONNX Model on Qualcomm® Hexagon™ DSP

AI Hub provides several pre-written demos that target Hexagon DSP on Windows.

Browse Python Demos

Python demos are available for:


Browse Native Demos

Native (C++) demos are available for several model types:

 

Run your Model in Python on Qualcomm Hexagon DSP

On your Windows on Snapdragon device, follow the steps outlined in our example notebook.

 

Your turn

With the above steps, you compiled your model for Snapdragon X Elite and ran it on device in just minutes. For next steps, browse our website for more models to try, or join our Slack community to ask questions and chat with others building AI experiences on Snapdragon platforms.

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries ("Qualcomm"). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.

Qualcomm-branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries.

About the Author
Kory Watson
Kory WatsonMachine Learning Engineer
Qualcomm relentlessly innovates to deliver intelligent computing everywhere, helping the world tackle some of its most important challenges. Our leading-edge AI, high performance, low-power computing, and unrivaled connectivity deliver proven solutions that transform major industries. At Qualcomm, we are engineering human progress.

Stay connected

Get the latest Qualcomm and industry information delivered to your inbox.

Subscribe
Manage your subscription

© Qualcomm Technologies, Inc. and/or its affiliated companies.

Snapdragon and Qualcomm branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries. Qualcomm patented technologies are licensed by Qualcomm Incorporated.

Note: Certain services and materials may require you to accept additional terms and conditions before accessing or using those items.

References to "Qualcomm" may mean Qualcomm Incorporated, or subsidiaries or business units within the Qualcomm corporate structure, as applicable.

Qualcomm Incorporated includes our licensing business, QTL, and the vast majority of our patent portfolio. Qualcomm Technologies, Inc., a subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of our engineering, research and development functions, and substantially all of our products and services businesses, including our QCT semiconductor business.

Materials that are as of a specific date, including but not limited to press releases, presentations, blog posts and webcasts, may have been superseded by subsequent events or disclosures.

Nothing in these materials is an offer to sell or license any of the services or materials referenced herein.