Project import generated by Copybara.

GitOrigin-RevId: 73d686c40057684f8bfaca285368bf1813f9fc26
This commit is contained in:
MediaPipe Team
2022-03-21 12:12:39 -07:00
committed by jqtang
parent e6c19885c6
commit cc6a2f7af6
266 changed files with 3658 additions and 1681 deletions
+47
View File
@@ -0,0 +1,47 @@
#include "mediapipe/gpu/gpu_buffer_storage.h"
namespace mediapipe {
namespace internal {
using StorageFactory = GpuBufferStorageRegistry::StorageFactory;
using StorageConverter = GpuBufferStorageRegistry::StorageConverter;
using RegistryToken = GpuBufferStorageRegistry::RegistryToken;
StorageFactory GpuBufferStorageRegistry::StorageFactoryForViewProvider(
TypeRef view_provider_type) {
auto it = factory_for_view_provider_.find(view_provider_type);
if (it == factory_for_view_provider_.end()) return nullptr;
return it->second;
}
StorageConverter GpuBufferStorageRegistry::StorageConverterForViewProvider(
TypeRef view_provider_type, TypeRef existing_storage_type) {
auto it = converter_for_view_provider_and_existing_storage_.find(
{view_provider_type, existing_storage_type});
if (it == converter_for_view_provider_and_existing_storage_.end())
return nullptr;
return it->second;
}
RegistryToken GpuBufferStorageRegistry::Register(
StorageFactory factory, std::vector<TypeRef> provider_hashes) {
// TODO: choose between multiple factories for same provider type.
for (const auto p : provider_hashes) {
factory_for_view_provider_[p] = factory;
}
return {};
}
RegistryToken GpuBufferStorageRegistry::Register(
StorageConverter converter, std::vector<TypeRef> provider_hashes,
TypeRef source_storage) {
// TODO: choose between multiple converters for same provider type.
for (const auto p : provider_hashes) {
converter_for_view_provider_and_existing_storage_[{p, source_storage}] =
converter;
}
return {};
}
} // namespace internal
} // namespace mediapipe