Using DeviceInfo instead of CLDevice.
PiperOrigin-RevId: 335772168 Change-Id: I02d334a87c2d8495ed7ed96dbdc31f4945b2cd3b
This commit is contained in:
parent
abce641853
commit
31e4a59c18
tensorflow/lite/delegates/gpu/cl
@ -286,6 +286,7 @@ cc_library(
|
||||
":cl_command_queue",
|
||||
":cl_context",
|
||||
":cl_device",
|
||||
":device_info",
|
||||
":precision",
|
||||
":program_cache",
|
||||
":tensor",
|
||||
|
@ -677,12 +677,13 @@ class InferenceBuilderImpl : public InferenceBuilder {
|
||||
if (GetRelativeImportance(options, InferencePriority::MIN_LATENCY,
|
||||
InferencePriority::MIN_MEMORY_USAGE) ==
|
||||
PriorityImportance::HIGHER) {
|
||||
preferred_storage_types = {GetFastestStorageType(environment_->device()),
|
||||
TensorStorageType::BUFFER};
|
||||
} else {
|
||||
preferred_storage_types = {
|
||||
GetStorageTypeWithMinimalMemoryConsumption(environment_->device()),
|
||||
GetFastestStorageType(environment_->device().GetInfo()),
|
||||
TensorStorageType::BUFFER};
|
||||
} else {
|
||||
preferred_storage_types = {GetStorageTypeWithMinimalMemoryConsumption(
|
||||
environment_->device().GetInfo()),
|
||||
TensorStorageType::BUFFER};
|
||||
}
|
||||
|
||||
for (TensorStorageType storage_type : preferred_storage_types) {
|
||||
|
@ -73,6 +73,7 @@ class CLDevice {
|
||||
bool SupportsOneLayerTextureArray() const;
|
||||
void DisableOneLayerTextureArray();
|
||||
|
||||
const DeviceInfo& GetInfo() const { return info_; }
|
||||
// We update device info during context creation, so as supported texture
|
||||
// formats can be requested from context only.
|
||||
mutable DeviceInfo info_;
|
||||
|
@ -171,54 +171,54 @@ bool Environment::IsSupported(TensorStorageType storage_type) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
TensorStorageType GetFastestStorageType(const CLDevice& gpu) {
|
||||
if (gpu.IsAdreno()) {
|
||||
if (gpu.IsAdreno6xxOrHigher()) {
|
||||
TensorStorageType GetFastestStorageType(const DeviceInfo& gpu_info) {
|
||||
if (gpu_info.IsAdreno()) {
|
||||
if (gpu_info.IsAdreno6xxOrHigher()) {
|
||||
return TensorStorageType::TEXTURE_ARRAY;
|
||||
} else {
|
||||
return TensorStorageType::TEXTURE_2D;
|
||||
}
|
||||
} else if (gpu.IsPowerVR()) {
|
||||
} else if (gpu_info.IsPowerVR()) {
|
||||
return TensorStorageType::TEXTURE_2D;
|
||||
} else if (gpu.IsMali()) {
|
||||
const MaliInfo mali_info = gpu.info_.mali_info;
|
||||
} else if (gpu_info.IsMali()) {
|
||||
const MaliInfo mali_info = gpu_info.mali_info;
|
||||
if (mali_info.IsMaliT8xx() || mali_info.IsBifrostGen3() ||
|
||||
mali_info.IsValhall()) {
|
||||
return TensorStorageType::TEXTURE_2D;
|
||||
} else {
|
||||
return TensorStorageType::BUFFER;
|
||||
}
|
||||
} else if (gpu.IsNvidia()) {
|
||||
return gpu.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsAMD()) {
|
||||
return gpu.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsIntel()) {
|
||||
} else if (gpu_info.IsNvidia()) {
|
||||
return gpu_info.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu_info.IsAMD()) {
|
||||
return gpu_info.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu_info.IsIntel()) {
|
||||
return TensorStorageType::BUFFER;
|
||||
}
|
||||
return TensorStorageType::BUFFER;
|
||||
}
|
||||
|
||||
TensorStorageType GetStorageTypeWithMinimalMemoryConsumption(
|
||||
const CLDevice& gpu) {
|
||||
if (gpu.IsAdreno()) {
|
||||
if (gpu.IsAdreno3xx() || gpu.IsAdreno4xx()) {
|
||||
const DeviceInfo& gpu_info) {
|
||||
if (gpu_info.IsAdreno()) {
|
||||
if (gpu_info.IsAdreno3xx() || gpu_info.IsAdreno4xx()) {
|
||||
return TensorStorageType::BUFFER;
|
||||
} else {
|
||||
return TensorStorageType::IMAGE_BUFFER;
|
||||
}
|
||||
} else if (gpu.IsPowerVR()) {
|
||||
} else if (gpu_info.IsPowerVR()) {
|
||||
return TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsMali()) {
|
||||
} else if (gpu_info.IsMali()) {
|
||||
return TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsNvidia()) {
|
||||
return gpu.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsAMD()) {
|
||||
return gpu.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu.IsIntel()) {
|
||||
} else if (gpu_info.IsNvidia()) {
|
||||
return gpu_info.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu_info.IsAMD()) {
|
||||
return gpu_info.SupportsImageBuffer() ? TensorStorageType::IMAGE_BUFFER
|
||||
: TensorStorageType::BUFFER;
|
||||
} else if (gpu_info.IsIntel()) {
|
||||
return TensorStorageType::BUFFER;
|
||||
}
|
||||
return TensorStorageType::BUFFER;
|
||||
|
@ -19,6 +19,7 @@ limitations under the License.
|
||||
#include "tensorflow/lite/delegates/gpu/cl/cl_command_queue.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/cl_context.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/cl_device.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/device_info.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/precision.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/program_cache.h"
|
||||
#include "tensorflow/lite/delegates/gpu/cl/tensor_type.h"
|
||||
@ -74,9 +75,9 @@ class Environment {
|
||||
ProgramCache program_cache_;
|
||||
};
|
||||
|
||||
TensorStorageType GetFastestStorageType(const CLDevice& gpu);
|
||||
TensorStorageType GetFastestStorageType(const DeviceInfo& gpu_info);
|
||||
TensorStorageType GetStorageTypeWithMinimalMemoryConsumption(
|
||||
const CLDevice& gpu);
|
||||
const DeviceInfo& gpu_info);
|
||||
|
||||
absl::Status CreateEnvironment(Environment* result);
|
||||
|
||||
|
@ -43,7 +43,7 @@ absl::Status RunModelSample(const std::string& model_name) {
|
||||
create_info.precision = env.IsSupported(CalculationsPrecision::F16)
|
||||
? CalculationsPrecision::F16
|
||||
: CalculationsPrecision::F32;
|
||||
create_info.storage_type = GetFastestStorageType(env.device());
|
||||
create_info.storage_type = GetFastestStorageType(env.device().GetInfo());
|
||||
create_info.hints.Add(ModelHints::kAllowSpecialKernels);
|
||||
std::cout << "Precision: " << ToString(create_info.precision) << std::endl;
|
||||
std::cout << "Storage type: " << ToString(create_info.storage_type)
|
||||
|
Loading…
Reference in New Issue
Block a user