TensorFlow Serving C++ API Documentation
|
Public Types | |
using | Creator = std::function< Status(std::unique_ptr< ServableType > *)> |
using | CreatorWithMetadata = std::function< Status(const Metadata &, std::unique_ptr< ServableType > *)> |
using | CreatorVariant = absl::variant< Creator, CreatorWithMetadata > |
using | ResourceEstimator = std::function< Status(ResourceAllocation *)> |
Public Member Functions | |
SimpleLoader (Creator creator, ResourceEstimator resource_estimator) | |
SimpleLoader (CreatorWithMetadata creator_with_metadata, ResourceEstimator resource_estimator) | |
SimpleLoader (Creator creator, ResourceEstimator resource_estimator, ResourceEstimator post_load_resource_estimator) | |
SimpleLoader (CreatorWithMetadata creator_with_metadata, ResourceEstimator resource_estimator, ResourceEstimator post_load_resource_estimator) | |
SimpleLoader (CreatorVariant creator_variant, ResourceEstimator resource_estimator, absl::optional< ResourceEstimator > post_load_resource_estimator) | |
Status | EstimateResources (ResourceAllocation *estimate) const override |
Status | Load () override |
Status | LoadWithMetadata (const Metadata &metadata) override |
void | Unload () override |
AnyPtr | servable () override |
![]() | |
virtual | ~Loader ()=default |
Static Public Member Functions | |
static ResourceEstimator | EstimateNoResources () |
Definition at line 72 of file simple_loader.h.
|
overridevirtual |
Estimates the resources a servable will use.
IMPORTANT: This method's implementation must obey following requirements, which enable the serving system to reason correctly about which servables can be loaded safely:
Implements tensorflow::serving::Loader.
Definition at line 279 of file simple_loader.h.
|
overridevirtual |
Fetches any data that needs to be loaded before using the servable returned by servable(). May use no more resources than the estimate reported by EstimateResources().
If implementing Load(), you don't have to override LoadWithMetadata().
Reimplemented from tensorflow::serving::Loader.
Definition at line 294 of file simple_loader.h.
|
overridevirtual |
Similar to the above method, but takes Metadata as a param, which may be used by the loader implementation appropriately.
If you're overriding LoadWithMetadata(), because you can use the metadata appropriately, you can skip overriding Load().
Reimplemented from tensorflow::serving::Loader.
Definition at line 306 of file simple_loader.h.
|
inlineoverridevirtual |
Returns an opaque interface to the underlying servable object. The caller should know the precise type of the interface in order to make actual use of it. For example:
CustomLoader implementation:
class CustomLoader : public Loader { public: ... Status Load() override { servable_ = ...; } AnyPtr servable() override { return servable_; } private: CustomServable* servable_ = nullptr; };
Serving user request:
ServableHandle<CustomServable> handle = ... CustomServable* servable = handle.get(); servable->...
If servable() is called after successful Load() and before Unload(), it returns a valid, non-null AnyPtr object. If called before a successful Load() call or after Unload(), it returns null AnyPtr.
Implements tensorflow::serving::Loader.
Definition at line 133 of file simple_loader.h.
|
overridevirtual |
Frees any resources allocated during Load() (except perhaps for resources shared across servables that are still needed for other active ones). The loader does not need to return to the "new" state (i.e. Load() cannot be called after Unload()).
Implements tensorflow::serving::Loader.
Definition at line 352 of file simple_loader.h.