Session

The First Step in Making Predictions

NatML exposes the Session type for managing prediction sessions with a given Predictor:

type Session {
    ...
}

Sessions created for EDGE predictors can be cached on-device, allowing a single session to be used across the lifetime of an app install.

Sessions should only be cached on the device that created the session. A single session will not work across different devices.

Identifying the Session

type Session {
    # Session ID.
    id: ID!
}

Sessions are uniquely identified with an id. This id can be used in mutations that require specifying a session.

Inspecting the Predictor

type Session {
    # Predictor for which this session was made.
    predictor: Predictor!
}

Sessions are always bound to a Predictor.

Inspecting the Platform

type Session {
    # Session device platform.
    platform: Platform!
}

Sessions are always created for a specific Device which specifies its platform:

Platform

enum Platform {
    # Android.
    ANDROID
    # iOS.
    IOS
    # Linux.
    LINUX
    # macOS.
    MACOS
    # Browser, WebGL, or other web platform.
    WEB
    # Windows.
    WINDOWS
}

The platform can be used to infer the format of the model graph that is served to the device.

Fetching the Model Graph

type Session {
    # Session graph data.
    graph: URL!
}

Sessions contain a pre-signed URL to the model graph. This graph should be downloaded by the client and used to create an on-device inference session.

The format of the model graph will vary depending on the device platform.

The graph URL is valid for 10 minutes, so use it to fetch the model graph immediately.

Inspecting the Graph Format

type Session {
    # Session graph format.
    format: GraphFormat
}

Sessions provide information about the format of the returned graph.

Graph Format

enum GraphFormat {
    # Apple CoreML.
    COREML
    # Open Neural Network Exchange.
    ONNX
    # TensorFlow Lite.
    TFLITE
    # PyTorch TorchScript.
    TORCHSCRIPT
}

NatML automatically converts uploaded ML models and delivers the correct format for a given platform.

Last updated