Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
viam::sdk::MLModelService Class Referenceabstract

Represents a machine trained learning model instance. More...

#include "services/mlmodel/mlmodel.hpp"

+ Inheritance diagram for viam::sdk::MLModelService:

Classes

struct  metadata
 
struct  tensor_info
 

Public Types

template<typename T >
using tensor_view = typename make_tensor_view_<T>::type
 
using signed_integral_base_types
 
using unsigned_integral_base_types
 
using integral_base_types
 
using fp_base_types = boost::mpl::list<float, double>
 
using base_types = boost::mpl::joint_view<integral_base_types, fp_base_types>
 
using tensor_view_types
 
using tensor_views = boost::make_variant_over<tensor_view_types>::type
 
using named_tensor_views = std::unordered_map<std::string, tensor_views>
 

Public Member Functions

API api () const override
 Returns the API associated with a particular resource.
 
std::shared_ptr< named_tensor_views > infer (const named_tensor_views &inputs)
 Runs the model against the input tensors and returns inference results as tensors.
 
virtual std::shared_ptr< named_tensor_views > infer (const named_tensor_views &inputs, const AttributeMap &extra)=0
 Runs the model against the input tensors and returns inference results as tensors.
 
struct metadata metadata ()
 Returns metadata describing the inputs and outputs of the model.
 
virtual struct metadata metadata (const AttributeMap &extra)=0
 Returns metadata describing the inputs and outputs of the model.
 
- Public Member Functions inherited from viam::sdk::Service
viam::common::v1::ResourceName get_resource_name (std::string name) const override
 Returns a ResourceName for a particular resource name.
 
- Public Member Functions inherited from viam::sdk::Resource
 Resource (std::string name)
 
virtual std::string name () const
 Return the resource's name.
 

Static Public Member Functions

template<typename T >
static tensor_view< T > make_tensor_view (const T *data, std::size_t size, typename tensor_view< T >::shape_type shape)
 

Protected Member Functions

 MLModelService (std::string name)
 
- Protected Member Functions inherited from viam::sdk::Service
 Service (std::string name)
 

Detailed Description

Represents a machine trained learning model instance.

This class acts as an abstract base class to be used by any driver implementing an MLModel. It is also used as the base class for the gRPC client for communicating with a remote MLModel instance.

Member Typedef Documentation

◆ integral_base_types

using viam::sdk::MLModelService::integral_base_types
Initial value:
boost::mpl::joint_view<signed_integral_base_types, unsigned_integral_base_types>

◆ signed_integral_base_types

using viam::sdk::MLModelService::signed_integral_base_types
Initial value:
boost::mpl::list<std::int8_t, std::int16_t, std::int32_t, std::int64_t>

◆ tensor_view_types

using viam::sdk::MLModelService::tensor_view_types
Initial value:
boost::mpl::transform_view<base_types, make_tensor_view_<boost::mpl::placeholders::_1>>

◆ unsigned_integral_base_types

using viam::sdk::MLModelService::unsigned_integral_base_types
Initial value:
boost::mpl::transform_view<signed_integral_base_types,
std::make_unsigned<boost::mpl::placeholders::_1>>

Member Function Documentation

◆ api()

API viam::sdk::MLModelService::api ( ) const
overridevirtual

Returns the API associated with a particular resource.

Implements viam::sdk::Resource.

◆ infer() [1/2]

std::shared_ptr< named_tensor_views > viam::sdk::MLModelService::infer ( const named_tensor_views & inputs)
inline

Runs the model against the input tensors and returns inference results as tensors.

Parameters
`inputs`The input tensors on which to run inference.
Returns
The results of the inference as a shared pointer to named_tensor_views. The data viewed by the views is only valid for the lifetime of the returned shared_ptr.

◆ infer() [2/2]

virtual std::shared_ptr< named_tensor_views > viam::sdk::MLModelService::infer ( const named_tensor_views & inputs,
const AttributeMap & extra )
pure virtual

Runs the model against the input tensors and returns inference results as tensors.

Parameters
`inputs`The input tensors on which to run inference.
`extra`Any additional arguments to the method.
Returns
The results of the inference as a shared pointer to named_tensor_views. The data viewed by the views is only valid for the lifetime of the returned shared_ptr.

Implemented in viam::sdk::impl::MLModelServiceClient, and viam::sdk::impl::MLModelServiceClient.

◆ metadata()

virtual struct metadata viam::sdk::MLModelService::metadata ( const AttributeMap & extra)
pure virtual

Returns metadata describing the inputs and outputs of the model.

Parameters
`extra`Any additional arguments to the method.

Implemented in viam::sdk::impl::MLModelServiceClient, and viam::sdk::impl::MLModelServiceClient.


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