model

package module
v0.0.0-...-073b321 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

CTN tensor model plugins

This public CTN library binds the reusable model types in res/int/model to model.tensor/v1. CTN, Cymonkey, and other Ext hosts can each open a sealed provider package directly. The application selects the package and model store, reviews the package digest, and authorizes calls. The application opens the provider through Ext using its own host session.

Contract

A provider exposes model.tensor.infer through Ext. The request contains an absolute model-store root, a provider/name@version reference, and 1 to 64 float32 tensors. The response contains 1 to 64 float32 tensors. Tensor bytes use JSON base64 and each direction is limited to 16 MiB of raw tensor data. See the request and response fixtures. Host and guest implementations can use any language that supports Ext's plugin protocol.

Use from an Ext host

  1. Build a provider guest, then seal its executable with PackageExecutable and install the package with the Ext package store. The executable's entry takes the run argument. Ext provides native guests for Core ML on macOS and ONNX Runtime on Windows and Linux.
  2. Use store.ResolveEntrypoint with the package ID, ContractName, ContractVersion, Protocol, and the consumer's reviewed package digest. Open that executable with the Ext host, pass run, and supply the host's authorization and any required runtime environment. Recheck the reviewed digest before launch.
  3. Call NewProcessClient(process).Infer(ctx, request) and close the process when finished. Use NewClient for a host that already has a typed Ext session. Guests written in Go can use RegisterProvider or ServeCurrentExecutable.

Workflows such as image resizing, decoding YOLO output into detections, and deciding which provider to use sit above this tensor contract. The existing CTN CLI is another consumer of the same capability.

Use from CTN

CTN operates on installed and explicitly trusted provider packages:

ext package pack --descriptor /path/to/descriptor.json --protocol model.tensor/v1 \
  --binary /path/to/provider --output /path/to/package
ext install /path/to/package
ext ctn model provider list
ext package trust onnxruntime
ext ctn model run --provider onnxruntime /absolute/model-store \
  onnxruntime/model@v1 /path/to/tensors.json
ext package untrust onnxruntime

tensors.json contains a tensors array with the shape, format, and base64 data for each tensor. model run returns the same shape or writes the response to a new file with --output FILE.

Documentation

Overview

Package model bridges res/int/model tensor providers to the Ext plugin contract. The wire contract is language-neutral; this package supplies Go host and guest helpers. A host still chooses and trusts a sealed provider package.

Index

Constants

View Source
const ContractName = "model.tensor"
View Source
const ContractVersion = "v1"
View Source
const MaxWireTensorBytes = 16 << 20
View Source
const Protocol = ContractName + "/" + ContractVersion

Variables

View Source
var ContractRef = plugin.ContractRef{Name: ContractName, Version: ContractVersion}

Functions

func PackageExecutable

func PackageExecutable(options ExecutablePackage) (packagekit.Manifest, error)

PackageExecutable seals a model.tensor/v1 guest without installing it.

func RegisterProvider

func RegisterProvider(registry *author.Registry, provider domain.Provider, authorize func(context.Context, plugin.Request) error) (*plugin.Descriptor, error)

RegisterProvider serves a selected native provider. The guest reopens and verifies the model bundle on every call, and closes the native session. The authorize callback must enforce guest-side access policy.

func ServeCurrentExecutable

func ServeCurrentExecutable(ctx context.Context, id, version string, provider domain.Provider, authorize func(context.Context, plugin.Request) error) error

ServeCurrentExecutable binds the guest identity to the running executable.

func ServeStdio

func ServeStdio(ctx context.Context, id plugin.Identity, provider domain.Provider, authorize func(context.Context, plugin.Request) error) error

ServeStdio exposes one explicitly selected provider over Ext JSON-line.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls a model.tensor/v1 guest through an already authorized session.

func NewClient

func NewClient(caller author.Caller) *Client

func NewProcessClient

func NewProcessClient(process ProcessCaller) *Client

NewProcessClient wraps a running package opened by an Ext host. The caller owns the process lifetime, package trust and authorization.

func (*Client) Infer

func (c *Client) Infer(ctx context.Context, request InferRequest) (InferResponse, error)

type ExecutablePackage

type ExecutablePackage struct {
	ID, Version, Binary, OutputDir, OS, Arch string
}

type InferRequest

type InferRequest struct {
	Root      string          `json:"root"`
	Reference string          `json:"reference"`
	Inputs    []domain.Tensor `json:"inputs"`
}

func (InferRequest) Validate

func (r InferRequest) Validate() error

type InferResponse

type InferResponse struct {
	Outputs []domain.Tensor `json:"outputs"`
}

func (InferResponse) Validate

func (r InferResponse) Validate() error

type ProcessCaller

type ProcessCaller interface {
	Call(context.Context, string, any, any) error
}

ProcessCaller calls a dotted method on an already authorized Ext process. The process returned by the Ext host package implements this interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL