Unity
  • NatML for Unity
  • Preliminaries
    • Getting Started
    • Requirements
  • Workflows
    • Core Concepts
    • Fetching Models
    • Using Predictors
  • Authoring
    • Creating Predictors
    • Distributing Predictors
  • API Reference
    • IMLPredictor
    • MLModel
      • MLEdgeModel
        • Configuration
      • MLCloudModel
    • MLFeature
      • MLArrayFeature
      • MLImageFeature
      • MLStringFeature
      • MLAudioFeature
      • MLVideoFeature
      • MLDepthFeature
      • MLXRCpuDepthFeature
    • MLFeatureType
      • MLArrayType
      • MLAudioType
      • MLImageType
      • MLVideoType
      • MLStringType
    • MLPredictorExtensions
  • Integrations
    • Media Devices
    • Augmented Reality
    • Video Recording
  • Insiders
    • Changelog
    • Open Source
    • GitHub
    • Discord
    • Blog
Powered by GitBook
On this page
  • Creating the Model Configuration
  • Specifying the Compute Target
  • Compute Target
  • Specifying the Compute Device

Was this helpful?

  1. API Reference
  2. MLModel
  3. MLEdgeModel

Configuration

class MLEdgeModel.Configuration

The Configuration type provides the ability to customize how edge models are created and executed on the local device.

Creating the Model Configuration

/// <summary>
/// Create a configuration
/// </summary>
Configuration ();

The Configuration defines a trivial constructor.

Specifying the Compute Target

/// <summary>
/// Specify the compute target used for model predictions.
/// </summary>
ComputeTarget computeTarget { get; set; }

The computeTarget is used to specify the compute target that will be used to accelerate model predictions:

Compute Target

/// <summary>
/// Compute target used for model predictions.
/// </summary>
enum ComputeTarget : int {
    /// <summary>
    /// Use the default compute target for the given platform.
    /// </summary>
    Default = 0,
    /// <summary>
    /// Use the CPU.
    /// </summary>
    CPU     = 1 << 0,
    /// <summary>
    /// Use the GPU.
    /// </summary>
    GPU     = 1 << 1,
    /// <summary>
    /// Use the neural processing unit.
    /// </summary>
    NPU     = 1 << 2,
    /// <summary>
    /// Use all available compute targets including the CPU, GPU, and neural processing units.
    /// </summary>
    All     = CPU | GPU | NPU,
}

Specifying the Compute Device

/// <summary>
/// Specify the compute device used for model predictions.
/// The native type of this pointer is platform-specific.
/// </summary>
IntPtr computeDevice { get; set; }

On systems with multiple GPU's, the model data allows for specifying the preferred compute device for accelerating model predictions.

Set this field to IntPtr.Zero to use the default compute device.

The computeDevice is exposed as an opaque pointer to a platform-specific type:

PreviousMLEdgeModelNextMLCloudModel

Last updated 2 years ago

Was this helpful?

The ComputeTarget enumeration is defined in the class.

On iOS and macOS, this pointer is an .

On Windows, this pointer is an .

MLEdgeModel
id<MTLDevice>
ID3D12Device