Compute Library
 22.05
TensorCache Class Reference

Stores RawTensor categorised by the image they are created from including name, format and channel. More...

#include <TensorCache.h>

Public Member Functions

RawTensorfind (std::tuple< const std::string &, Format > key)
 Search the cache for a tensor of created from the specified image and format. More...
 
RawTensorfind (std::tuple< const std::string &, Format, Channel > key)
 Search the cache for a tensor of created from the specified image, format and channel. More...
 
RawTensoradd (std::tuple< const std::string &, Format > key, RawTensor raw)
 Add the given tensor to the cache. More...
 
RawTensoradd (std::tuple< const std::string &, Format, Channel > key, RawTensor raw)
 Add the given tensor to the cache. More...
 

Detailed Description

Stores RawTensor categorised by the image they are created from including name, format and channel.

Definition at line 42 of file TensorCache.h.

Member Function Documentation

◆ add() [1/2]

RawTensor & add ( std::tuple< const std::string &, Format key,
RawTensor  raw 
)
inline

Add the given tensor to the cache.

Can later be found under the given image name and format.

Parameters
[in]keyKey under which to store the tensor. Consists of image name and format.
[in]rawRaw tensor to be stored.
Returns
A reference to the cached tensor.

Definition at line 107 of file TensorCache.h.

Referenced by AssetsLibrary::fill().

108 {
109  std::lock_guard<arm_compute::Mutex> lock(_raw_tensor_cache_mutex);
110  return std::get<0>(_raw_tensor_cache.emplace(std::move(key), std::move(raw)))->second;
111 }

◆ add() [2/2]

RawTensor & add ( std::tuple< const std::string &, Format, Channel key,
RawTensor  raw 
)
inline

Add the given tensor to the cache.

Can later be found under the given image name, format and channel.

Parameters
[in]keyKey under which to store the tensor. Consists of image name, format and channel.
[in]rawRaw tensor to be stored.
Returns
A reference to the cached tensor.

Definition at line 113 of file TensorCache.h.

114 {
115  std::lock_guard<arm_compute::Mutex> lock(_raw_tensor_channel_cache_mutex);
116  return std::get<0>(_raw_tensor_channel_cache.emplace(std::move(key), std::move(raw)))->second;
117 }

◆ find() [1/2]

RawTensor * find ( std::tuple< const std::string &, Format key)
inline

Search the cache for a tensor of created from the specified image and format.

Parameters
[in]keyKey to look up the tensor. Consists of image name and format.
Returns
The cached tensor matching the image name and format if found. A nullptr otherwise.

Definition at line 95 of file TensorCache.h.

Referenced by AssetsLibrary::fill().

96 {
97  const auto it = _raw_tensor_cache.find(key);
98  return it == _raw_tensor_cache.end() ? nullptr : &it->second;
99 }

◆ find() [2/2]

RawTensor * find ( std::tuple< const std::string &, Format, Channel key)
inline

Search the cache for a tensor of created from the specified image, format and channel.

Parameters
[in]keyKey to look up the tensor. Consists of image name, format and channel.
Returns
The cached tensor matching the image name and format if found. A nullptr otherwise.

Definition at line 101 of file TensorCache.h.

102 {
103  const auto it = _raw_tensor_channel_cache.find(key);
104  return it == _raw_tensor_channel_cache.end() ? nullptr : &it->second;
105 }

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