docs.unity3d.com
Search Results for

    Show / Hide Table of Contents
    Note

    Sentis is now called Inference Engine. The documentation has moved to https://docs.unity3d.com/Packages/com.unity.ai.inference@latest. Refer to the new location for the latest updates and guidance. Make sure to update your bookmarks and references accordingly.

    Create an engine to run a model

    To run a model, you need to create a worker. A worker is the engine that breaks the model down into executable tasks and schedules the tasks to run on a backend, usually the GPU or CPU.

    Create a Worker

    Use new Worker(...) to create a worker. You must specify a backend type, which tells Sentis where to run the worker and a runtime model.

    For example, the following code creates a worker that runs on the GPU using Sentis compute shaders.

    using UnityEngine;
    using Unity.Sentis;
    
    public class CreateWorker : MonoBehaviour
    {
        ModelAsset modelAsset;
        Model runtimeModel;
        Worker worker;
    
        void Start()
        {
            runtimeModel = ModelLoader.Load(modelAsset);
            worker = new Worker(runtimeModel, BackendType.GPUCompute);
        }
    }
    

    Backend types

    Sentis provides CPU and GPU backend types. To understand how Sentis executes operations using the different backends, refer to How Sentis runs a model.

    If a backend type doesn't support a Sentis layer in a model, the worker will assert. Refer to Supported ONNX operators for more information.

    Among the backend types, BackendType.GPUCompute and BackendType.CPU are the fastest. Use BackendType.GPUPixel only if your platform does not support compute shaders. To check if your runtime platform supports compute shaders, use SystemInfo.supportsComputeShaders.

    If you use BackendType.GPUCompute with the DirectX12 Graphics API on a supported platform, Sentis uses DirectML to accelerate inference. Refer to Supported ONNX operators for information.

    If you use BackendType.CPU with WebGL, Burst compiles to WebAssembly code which might be slow. For more information, refer to Getting started with WebGL development.

    The speed of model execution depends on the platform's support for multithreading in Burst or its full support for compute shaders. You can profile a model to understand the performance of a model.

    Additional resources

    • Create a runtime model
    • How Sentis runs a model
    • Supported ONNX operators
    • Run a model
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)