24 #ifndef ARM_COMPUTE_TEST_TENSOR_CACHE_H 25 #define ARM_COMPUTE_TEST_TENSOR_CACHE_H 63 RawTensor *
find(std::tuple<const std::string &, Format, Channel> key);
86 using FormatMap = std::map<std::tuple<std::string, Format>,
RawTensor>;
87 using ChannelMap = std::map<std::tuple<std::string, Format, Channel>, RawTensor>;
89 FormatMap _raw_tensor_cache{};
90 ChannelMap _raw_tensor_channel_cache{};
97 const auto it = _raw_tensor_cache.find(key);
98 return it == _raw_tensor_cache.end() ? nullptr : &it->second;
103 const auto it = _raw_tensor_channel_cache.find(key);
104 return it == _raw_tensor_channel_cache.end() ? nullptr : &it->second;
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;
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;
Subclass of SimpleTensor using uint8_t as value type.
Stores RawTensor categorised by the image they are created from including name, format and channel...
std::mutex Mutex
Wrapper of Mutex data-object.
Copyright (c) 2017-2022 Arm Limited.
RawTensor & add(std::tuple< const std::string &, Format > key, RawTensor raw)
Add the given tensor to the cache.
RawTensor * find(std::tuple< const std::string &, Format > key)
Search the cache for a tensor of created from the specified image and format.