mizchi/webnn/backend/webnn does not have a README file
fn TfliteCpuRunner::run(self : TfliteCpuRunner, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput] raisepub struct TfliteCpuRunnerCache {
entries : Map[String, TfliteCpuRunner]
entry_bytes : Map[String, Int]
last_access : Map[String, Int]
capacity_ : Int
byte_capacity_ : Int
resident_bytes_ : Int
access_counter : Int
hits_ : Int
misses_ : Int
evictions_ : Int
}fn TfliteCpuRunnerCache::new_with_capacity(capacity : Int) -> TfliteCpuRunnerCache raise TensorErrorfn TfliteCpuRunnerCache::new_with_limits(capacity : Int, byte_capacity : Int) -> TfliteCpuRunnerCache raise TensorErrorasync fn TfliteCpuRunnerCache::run(self : TfliteCpuRunnerCache, bytes : Bytes, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]fn TfliteCpuRunnerCache::run_artifact(self : TfliteCpuRunnerCache, artifact : TfliteModelArtifact, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput] raisepub struct TfliteCpuRunnerCacheMetrics {
hits_ : Int
misses_ : Int
evictions_ : Int
entries_ : Int
resident_bytes_ : Int
byte_capacity_ : Int
}pub struct TfliteModelArtifact {
bytes_ : Bytes
digest_ : String
}pub struct TfliteRunner {
program : WebNNProgram
inputs : Array[TfliteRuntimeTensor]
outputs : Array[TfliteRuntimeTensor]
}async fn TfliteRunner::compile_pool(bytes : Bytes, preference : DevicePreference, execution_pool_size : Int) -> TfliteRunnerasync fn TfliteRunner::run(self : TfliteRunner, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]pub struct TfliteRunnerCache {
entries : Map[String, TfliteRunner]
entry_bytes : Map[String, Int]
last_access : Map[String, Int]
capacity_ : Int
byte_capacity_ : Int
generation : Ref[Int]
resident_bytes_ : Int
access_counter : Int
hits_ : Int
misses_ : Int
evictions_ : Int
}fn TfliteRunnerCache::new_with_limits(capacity : Int, byte_capacity : Int) -> TfliteRunnerCache raise TensorErrorasync fn TfliteRunnerCache::run(self : TfliteRunnerCache, bytes : Bytes, preference : DevicePreference, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]async fn TfliteRunnerCache::run_artifact(self : TfliteRunnerCache, artifact : TfliteModelArtifact, preference : DevicePreference, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]async fn TfliteRunnerCache::run_artifact_pool(self : TfliteRunnerCache, artifact : TfliteModelArtifact, preference : DevicePreference, execution_pool_size : Int, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]async fn TfliteRunnerCache::run_artifact_pool_with_compiler(self : TfliteRunnerCache, artifact : TfliteModelArtifact, preference : DevicePreference, execution_pool_size : Int, input_values : Array[TfliteRunnerInput], compile : () -> Promise[TfliteRunner]) -> Array[TfliteRunnerOutput]async fn TfliteRunnerCache::run_pool(self : TfliteRunnerCache, bytes : Bytes, preference : DevicePreference, execution_pool_size : Int, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]pub struct TfliteRunnerCacheKey {
model_digest_ : String
device_ : DevicePreference
execution_pool_size_ : Int
}fn TfliteRunnerCacheKey::new(model_digest : String, device : DevicePreference, execution_pool_size : Int) -> TfliteRunnerCacheKey raise TensorErrorpub struct TfliteRunnerCacheMetrics {
hits_ : Int
misses_ : Int
evictions_ : Int
entries_ : Int
resident_bytes_ : Int
byte_capacity_ : Int
}fn TfliteRunnerInput::float32(name : String, values : Array[Float]) -> TfliteRunnerInput raise TensorErrorfn TfliteRunnerInput::quantized(name : String, values : Array[Int]) -> TfliteRunnerInput raise TensorErrorpub struct WebNNCapabilities {
contract_ : WebNNContextContract
preference_ : DevicePreference
preferred_input_layout_ : InputLayout
op_support_limits_available_ : Bool
tensor_io_available_ : Bool
supported_operators_ : Array[String]
}pub struct WebNNExecution {
context : MLContext
graph : MLGraph
input_specs : Array[WebNNValueSpec]
inputs : Array[MLTensor]
output_specs : Array[WebNNValueSpec]
outputs : Array[MLTensor]
}async fn WebNNExecution::run_named(self : WebNNExecution, input_values : Array[WebNNNamedValues]) -> Array[WebNNNamedValues]pub struct WebNNGraphBuilder {
context : MLContext
builder : MLGraphBuilder
supported_operators_ : Array[String]
}async fn WebNNGraphBuilder::compile_litert_program(self : WebNNGraphBuilder, model : LiteRtModel) -> WebNNProgramasync fn WebNNGraphBuilder::compile_litert_program_pool(self : WebNNGraphBuilder, model : LiteRtModel, pool_size : Int) -> WebNNProgramasync fn WebNNGraphBuilder::compile_named(self : WebNNGraphBuilder, inputs : Array[WebNNInput], outputs : Array[WebNNOutput]) -> WebNNSessionasync fn WebNNGraphBuilder::compile_program_named(self : WebNNGraphBuilder, inputs : Array[WebNNInput], outputs : Array[WebNNOutput]) -> WebNNProgramasync fn WebNNGraphBuilder::compile_program_pool_named(self : WebNNGraphBuilder, inputs : Array[WebNNInput], outputs : Array[WebNNOutput], pool_size : Int) -> WebNNProgramasync fn WebNNGraphBuilder::compile_program_pool_single(self : WebNNGraphBuilder, input : WebNNInput, output_name : String, output : WebNNTensor, pool_size : Int) -> WebNNProgramasync fn WebNNGraphBuilder::compile_program_single(self : WebNNGraphBuilder, input : WebNNInput, output_name : String, output : WebNNTensor) -> WebNNProgramasync fn WebNNGraphBuilder::compile_single(self : WebNNGraphBuilder, input : WebNNInput, output_name : String, output : WebNNTensor) -> WebNNSessionfn WebNNGraphBuilder::constant(self : WebNNGraphBuilder, shape : Shape, values : Array[Float]) -> WebNNTensor raise TensorErrorfn WebNNGraphBuilder::input(self : WebNNGraphBuilder, name : String, shape : Shape) -> WebNNInput raise TensorErrorfn WebNNGraphBuilder::lower_litert(self : WebNNGraphBuilder, model : LiteRtModel) -> WebNNLoweredLiteRtGraph raisefn WebNNGraphBuilder::materialize_bert_encoder_stack(self : WebNNGraphBuilder, config : BertEncoderConfig, parameters : BertEncoderParameters, mask : AttentionMask?) -> BertEncoderStack[WebNNTensor] raise TensorErrorfn WebNNGraphBuilder::materialize_feed_forward(self : WebNNGraphBuilder, config : TransformerEncoderConfig, parameters : FeedForwardParameters) -> FeedForward[WebNNTensor] raise TensorErrorfn WebNNGraphBuilder::materialize_self_attention(self : WebNNGraphBuilder, config : SelfAttentionConfig, parameters : SelfAttentionParameters, mask : AttentionMask?) -> SelfAttention[WebNNTensor] raise TensorErrorfn WebNNGraphBuilder::materialize_transformer_encoder(self : WebNNGraphBuilder, config : TransformerEncoderConfig, parameters : TransformerEncoderParameters, mask : AttentionMask?) -> TransformerEncoderBlock[WebNNTensor] raise TensorErrorfn WebNNGraphBuilder::materialize_transformer_encoder_stack(self : WebNNGraphBuilder, config : TransformerEncoderStackConfig, parameters : TransformerEncoderStackParameters, mask : AttentionMask?) -> TransformerEncoderStack[WebNNTensor] raise TensorErrorfn WebNNGraphBuilder::output(self : WebNNGraphBuilder, name : String, tensor : WebNNTensor) -> WebNNOutput raise TensorErrorpub struct WebNNLoweredLiteRtGraph {
inputs_ : Array[WebNNInput]
outputs_ : Array[LiteRtLoweredValue[WebNNTensor]]
}fn WebNNLoweredLiteRtGraph::outputs(self : WebNNLoweredLiteRtGraph) -> Array[LiteRtLoweredValue[WebNNTensor]]fn WebNNNamedValues::new(name : String, values : Array[Float]) -> WebNNNamedValues raise TensorErrorpub struct WebNNProgram {
owner : WebNNGraphBuilder
executions : Array[WebNNExecution]
scheduler : WebNNProgramScheduler
}async fn WebNNProgram::run_named(self : WebNNProgram, input_values : Array[WebNNNamedValues]) -> Array[WebNNNamedValues]async fn WebNNProgramCache::run_named_or_compile(self : WebNNProgramCache, key : WebNNProgramCacheKey, input_values : Array[WebNNNamedValues], compile : () -> Promise[WebNNProgram]) -> (Array[WebNNNamedValues], Bool)async fn WebNNProgramCache::run_or_compile(self : WebNNProgramCache, key : WebNNProgramCacheKey, input_values : Array[Float], compile : () -> Promise[WebNNProgram]) -> (Array[Float], Bool)pub struct WebNNProgramCacheKey {
graph_hash_ : String
device_ : DevicePreference
input_shapes_ : Array[Shape]
execution_pool_size_ : Int
}fn WebNNProgramCacheKey::new(graph_hash : String, device : DevicePreference, input_shapes : Array[Shape]) -> WebNNProgramCacheKey raise TensorErrorfn WebNNProgramCacheKey::new_with_pool(graph_hash : String, device : DevicePreference, input_shapes : Array[Shape], execution_pool_size : Int) -> WebNNProgramCacheKey raise TensorErrorpub struct WebNNRuntime {
preference_ : DevicePreference
execution_pool_size_ : Int
fallback_ : WebNNRuntimeFallback
tflite_cache : TfliteRunnerCache
cpu_tflite_cache : TfliteCpuRunnerCache
cpu_fallbacks_ : Int
}fn WebNNRuntime::new_with_cache_limits(preference : DevicePreference, execution_pool_size : Int, cache_capacity : Int, cache_byte_capacity : Int, cpu_cache_capacity : Int, cpu_cache_byte_capacity : Int, fallback : WebNNRuntimeFallback) -> WebNNRuntime raise TensorErrorfn WebNNRuntime::new_with_cpu_fallback(preference : DevicePreference, execution_pool_size : Int, cache_capacity : Int) -> WebNNRuntime raise TensorErrorfn WebNNRuntime::new_with_options(preference : DevicePreference, execution_pool_size : Int, cache_capacity : Int, fallback : WebNNRuntimeFallback) -> WebNNRuntime raise TensorErrorfn WebNNRuntime::new_with_pool(preference : DevicePreference, execution_pool_size : Int) -> WebNNRuntime raise TensorErrorasync fn WebNNRuntime::run_prepared_tflite(self : WebNNRuntime, artifact : TfliteModelArtifact, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]async fn WebNNRuntime::run_tflite(self : WebNNRuntime, bytes : Bytes, input_values : Array[TfliteRunnerInput]) -> Array[TfliteRunnerOutput]pub struct WebNNRuntimeMetrics {
cache_ : TfliteRunnerCacheMetrics
cpu_cache_ : TfliteCpuRunnerCacheMetrics
cpu_fallbacks_ : Int
}pub struct WebNNSession {
context : MLContext
graph : MLGraph
input_specs : Array[WebNNValueSpec]
output_specs : Array[WebNNValueSpec]
}async fn WebNNSession::run_named(self : WebNNSession, input_values : Array[WebNNNamedValues]) -> Array[WebNNNamedValues]pub struct WebNNTensor {
builder : MLGraphBuilder
operand : MLOperand
shape_ : Shape
supported_operators : Array[String]
}impl TensorOps for WebNNTensorfn gather(self : WebNNTensor, indices : Array[Int], indices_shape : Shape, axis : Int) -> WebNNTensor raisefn layer_normalization(input : WebNNTensor, scale : WebNNTensor, bias : WebNNTensor, axes : Array[Int], epsilon : Float) -> WebNNTensor raiseWebNN backend and TFLite inference runtime for MoonBit
Dependencies