TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tensorflow::serving::SourceAdapter

This is an abstract class.

#include <source_adapter.h>

An abstraction for a module that receives aspired-version callbacks with data of type InputType and converts them into calls with data of type OutputType.

Summary

A common example uses InputType=StoragePath, OutputType=unique_ptr<Loader>, in which case the module "converts" each incoming storage path into a loader capable of loading a (particular type of) servable based on the path.

SourceAdapters are typically stateless. However, as with all Sources they can house state that is shared among multiple emitted servables. See the discussion in source.h.

Implementing subclasses supply an implementation of the Adapt() virtual method, which converts a servable version list from InputType to OutputType.

IMPORTANT: Every leaf derived class must call Detach() at the top of its destructor. (See documentation on TargetBase::Detach() in target.h.) Doing so ensures that no Adapt() calls are in flight during destruction of member variables.

Inheritance

Inherits from: TargetBase< InputType >, tensorflow::serving::Source< OutputType >

Constructors and Destructors

~SourceAdapter()

Public functions

Adapt(const StringPiece servable_name, std::vector< ServableData< InputType >> versions)=0
virtual std::vector< ServableData< OutputType > >
Given an InputType-based aspired-versions request, produces a corresponding OutputType-based request.
AdaptOneVersion(ServableData< InputType > input)
ServableData< OutputType >
Adapts a single servable data item. (Implemented on top of Adapt().)
SetAspiredVersions(const StringPiece servable_name, std::vector< ServableData< InputType >> versions) final
void
This method is implemented in terms of Adapt(), which the implementing subclass must supply.
SetAspiredVersionsCallback(typename Source< OutputType >::AspiredVersionsCallback callback) final
void

Protected functions

SourceAdapter()=default

Public functions

Adapt

virtual std::vector< ServableData< OutputType > > Adapt(
  const StringPiece servable_name,
  std::vector< ServableData< InputType >> versions
)=0

Given an InputType-based aspired-versions request, produces a corresponding OutputType-based request.

AdaptOneVersion

ServableData< OutputType > AdaptOneVersion(
  ServableData< InputType > input
)

Adapts a single servable data item. (Implemented on top of Adapt().)

SetAspiredVersions

void SetAspiredVersions(
  const StringPiece servable_name,
  std::vector< ServableData< InputType >> versions
) final

This method is implemented in terms of Adapt(), which the implementing subclass must supply.

SetAspiredVersionsCallback

void SetAspiredVersionsCallback(
  typename Source< OutputType >::AspiredVersionsCallback callback
) final

~SourceAdapter

virtual  ~SourceAdapter() override=0

Protected functions

SourceAdapter

 SourceAdapter()=default