ModelPackage

dicechess.engine.model.ModelPackage
See theModelPackage companion object
final case class ModelPackage(modelPath: Path, manifest: ModelManifest, role: ModelRole, schema: FeatureSchema)

A validated model package: an ONNX file, the manifest that describes it, and the two things the manifest's ids resolve to — the ModelRole the model may be wired into and the FeatureSchema whose rows it must be fed.

Holding this value is the proof that the checks ran. A host that has one can wire a search hook without re-deciding which extractor to use or whether the artifact fits: ModelPackage.extract is the only correct extractor for these bytes, and the role is the only correct place to put them.

Loading is deliberately cheap and session-free: it reads the manifest, digests the model file, and stops. The graph itself is checked once a session exists, through ModelPackage.validateSession — the one check that needs onnxruntime to open the file.

Attributes

Companion
object
Source
ModelPackage.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def extract: (GameState, Color) => Array[Float]

The feature extractor these bytes were trained on.

The feature extractor these bytes were trained on.

Attributes

Source
ModelPackage.scala
def featureCount: Int

Input width the session must declare — FeatureSchema.featureCount, already agreed with the manifest.

Input width the session must declare — FeatureSchema.featureCount, already agreed with the manifest.

Attributes

Source
ModelPackage.scala
def validateSession(session: OrtSession): Either[String, Unit]

Checks the loaded graph against the manifest's tensor contract. Call once, right after creating the session and before the first inference.

Checks the loaded graph against the manifest's tensor contract. Call once, right after creating the session and before the first inference.

Attributes

Source
ModelPackage.scala

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product