rustnn C and C++ API
WebNN graph construction and execution
Loading...
Searching...
No Matches
rustnn::MLContext Class Reference

Owns a backend context for graph compilation, tensors and dispatch. More...

#include <rustnn.hpp>

Public Member Functions

 MLContext (const MLContextOptions &options={})
 ~MLContext ()
 MLContext (const MLContext &)=delete
MLContext & operator= (const MLContext &)=delete
 MLContext (MLContext &&other) noexcept
MLContext & operator= (MLContext &&other) noexcept
MLTensor createTensor (const MLTensorDescriptor &descriptor)
 Allocate a backend tensor with the descriptor's host access flags.
template<typename T>
void writeTensor (const MLTensor &tensor, const std::vector< T > &data)
 Copy raw bytes from data into a writable tensor; T must match its storage.
template<typename T>
std::vector< T > readTensor (const MLTensor &tensor, std::size_t element_count)
 Copy a readable tensor into element_count values; T must match its storage.
void dispatch (MLGraph &graph, const std::vector< std::pair< std::string, const MLTensor * > > &inputs, const std::vector< std::pair< std::string, const MLTensor * > > &outputs)
 Execute a compiled graph with tensors bound by input and output name.

Detailed Description

Owns a backend context for graph compilation, tensors and dispatch.

Definition at line 243 of file rustnn.hpp.

Constructor & Destructor Documentation

◆ MLContext() [1/3]

rustnn::MLContext::MLContext ( const MLContextOptions & options = {})
inlineexplicit

Definition at line 245 of file rustnn.hpp.

◆ ~MLContext()

rustnn::MLContext::~MLContext ( )
inline

Definition at line 274 of file rustnn.hpp.

◆ MLContext() [2/3]

rustnn::MLContext::MLContext ( const MLContext & )
delete

◆ MLContext() [3/3]

rustnn::MLContext::MLContext ( MLContext && other)
inlinenoexcept

Definition at line 278 of file rustnn.hpp.

Member Function Documentation

◆ createTensor()

MLTensor rustnn::MLContext::createTensor ( const MLTensorDescriptor & descriptor)
inline

Allocate a backend tensor with the descriptor's host access flags.

Definition at line 289 of file rustnn.hpp.

◆ dispatch()

void rustnn::MLContext::dispatch ( MLGraph & graph,
const std::vector< std::pair< std::string, const MLTensor * > > & inputs,
const std::vector< std::pair< std::string, const MLTensor * > > & outputs )
inline

Execute a compiled graph with tensors bound by input and output name.

Definition at line 314 of file rustnn.hpp.

◆ operator=() [1/2]

MLContext & rustnn::MLContext::operator= ( const MLContext & )
delete

◆ operator=() [2/2]

MLContext & rustnn::MLContext::operator= ( MLContext && other)
inlinenoexcept

Definition at line 280 of file rustnn.hpp.

◆ readTensor()

template<typename T>
std::vector< T > rustnn::MLContext::readTensor ( const MLTensor & tensor,
std::size_t element_count )
inline

Copy a readable tensor into element_count values; T must match its storage.

Definition at line 305 of file rustnn.hpp.

◆ writeTensor()

template<typename T>
void rustnn::MLContext::writeTensor ( const MLTensor & tensor,
const std::vector< T > & data )
inline

Copy raw bytes from data into a writable tensor; T must match its storage.

Definition at line 297 of file rustnn.hpp.


The documentation for this class was generated from the following file: