Skip to content

Commit 55623ca

Browse files
ai-edge-botcopybara-github
authored andcommitted
Revert 731ee5 due to failing tests.
Reverts 731ee52 LiteRT-PiperOrigin-RevId: 828439725
1 parent d17fd00 commit 55623ca

File tree

6 files changed

+49
-153
lines changed

6 files changed

+49
-153
lines changed

litert/cc/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ litert_device_test(
357357
# "requires-gpu-nvidia",
358358
# ],
359359
# deps = [
360-
# ":litert_common",
361360
# ":litert_compiled_model",
362361
# ":litert_element_type",
363362
# ":litert_environment",

litert/cc/litert_compiled_model_gpu_test.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "litert/c/litert_event_type.h"
3030
#include "litert/c/litert_profiler_event.h"
3131
#include "litert/cc/internal/litert_platform_support.h"
32-
#include "litert/cc/litert_common.h"
3332
#include "litert/cc/litert_compiled_model.h"
3433
#include "litert/cc/litert_element_type.h"
3534
#include "litert/cc/litert_environment.h"
@@ -387,28 +386,6 @@ TEST_P(CompiledModelGpuTest, PartialDelegation) {
387386
}
388387
}
389388

390-
TEST_P(CompiledModelGpuTest, PartialDelegationNoCpuFallbackError) {
391-
constexpr const char* kModelPartilaFileName = "simple_cast_and_add_op.tflite";
392-
LITERT_ASSERT_OK_AND_ASSIGN(
393-
auto model,
394-
Model::CreateFromFile(testing::GetTestFilePath(kModelPartilaFileName)));
395-
396-
auto env = litert::Environment::Create({});
397-
ASSERT_TRUE(env);
398-
399-
auto compilation_options = Options::Create();
400-
compilation_options->SetHardwareAccelerators(HwAccelerators::kGpu);
401-
LITERT_ASSERT_OK_AND_ASSIGN(auto gpu_options, litert::GpuOptions::Create());
402-
LITERT_ASSERT_OK(
403-
gpu_options.EnableExternalTensorsMode(CompiledModelGpuTest::GetParam()));
404-
compilation_options->AddOpaqueOptions(std::move(gpu_options));
405-
406-
auto compiled_model_res =
407-
CompiledModel::Create(*env, model, *compilation_options);
408-
EXPECT_FALSE(compiled_model_res.HasValue());
409-
EXPECT_EQ(compiled_model_res.Error().Status(), kLiteRtStatusErrorCompilation);
410-
}
411-
412389
TEST_P(CompiledModelGpuTest, BasicAdd3dCstInt32) {
413390
constexpr const char* kInt32ModelFileName = "simple_add3d_cst_int32.tflite";
414391
constexpr const int32_t kInt32TestInput0Tensor[] = {1, 2, 3, 4, 5, 6};

litert/runtime/accelerators/xnnpack/xnnpack_accelerator.cc

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,6 @@ class CpuAccelerator final
109109
LiteRtUnwrapDelegate(delegate_wrapper, &xnnpack_delegate);
110110
TfLiteXNNPackDelegateDelete(xnnpack_delegate);
111111
}
112-
113-
// Returns true to indicate the XNNPack delegate is responsible for JIT
114-
// compilation.
115-
static LiteRtStatus IsTfLiteDelegateResponsibleForJitCompilation(
116-
LiteRtAcceleratorT* accelerator, bool* does_jit_compilation) {
117-
LITERT_RETURN_IF_ERROR(does_jit_compilation,
118-
litert::ErrorStatusBuilder::InvalidArgument())
119-
<< "`does_jit_compilation` pointer is null.";
120-
*does_jit_compilation = true;
121-
return kLiteRtStatusOk;
122-
}
123112
};
124113

125114
} // namespace
@@ -142,11 +131,6 @@ LiteRtStatus LiteRtRegisterCpuAccelerator(LiteRtEnvironment environment) {
142131
LITERT_ASSIGN_OR_RETURN(auto accelerator_impl,
143132
litert::CpuAccelerator::Create());
144133

145-
LITERT_RETURN_IF_ERROR(
146-
LiteRtSetIsAcceleratorDelegateResponsibleForJitCompilation(
147-
accelerator.get(), litert::CpuAccelerator::
148-
IsTfLiteDelegateResponsibleForJitCompilation));
149-
150134
LITERT_RETURN_IF_ERROR(LiteRtRegisterAccelerator(
151135
environment, accelerator.release(), accelerator_impl.release(),
152136
litert::CpuAccelerator::Destroy));

litert/tools/BUILD

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -399,35 +399,25 @@ cc_library(
399399
# )
400400
# copybara:uncomment_end
401401

402+
#copybara:comment_begin(google-only)
402403
cc_test(
403404
name = "benchmark_litert_model_test",
404405
srcs = ["benchmark_litert_model_test.cc"],
405406
data = ["//litert/test:testdata/mobilenet_v2_1.0_224.tflite"],
406-
deps = [
407-
":benchmark_litert_model",
408-
"//tflite/core/c:private_c_api_types",
409-
"//tflite/tools/benchmark:benchmark_model_lib",
410-
"//tflite/tools/benchmark:benchmark_params",
411-
"@com_google_googletest//:gtest_main",
412-
],
407+
tags = ["requires-gpu-nvidia"],
408+
deps =
409+
[
410+
":benchmark_litert_model",
411+
"@com_google_googletest//:gtest_main",
412+
# copybara:uncomment_begin(google-only)
413+
# "//litert/runtime/accelerators/gpu:ml_drift_cl_accelerator", # buildcleaner: keep
414+
# copybara:uncomment_end
415+
"//tflite/core/c:private_c_api_types",
416+
"//tflite/tools/benchmark:benchmark_model_lib",
417+
"//tflite/tools/benchmark:benchmark_params",
418+
],
413419
)
414-
415-
# copybara:uncomment_begin(google-only)
416-
# cc_test(
417-
# name = "benchmark_litert_model_gpu_test",
418-
# srcs = ["benchmark_litert_model_gpu_test.cc"],
419-
# data = ["//litert/test:testdata/mobilenet_v2_1.0_224.tflite"],
420-
# tags = ["requires-gpu-nvidia"],
421-
# deps = [
422-
# ":benchmark_litert_model",
423-
# "@com_google_googletest//:gtest_main",
424-
# "//litert/runtime/accelerators/gpu:ml_drift_cl_accelerator", # buildcleaner: keep
425-
# "//tflite/core/c:private_c_api_types",
426-
# "//tflite/tools/benchmark:benchmark_model_lib",
427-
# "//tflite/tools/benchmark:benchmark_params",
428-
# ],
429-
# )
430-
# copybara:uncomment_end
420+
#copybara:comment_end
431421

432422
cc_library(
433423
name = "tensor_utils",

litert/tools/benchmark_litert_model_gpu_test.cc

Lines changed: 0 additions & 89 deletions
This file was deleted.

litert/tools/benchmark_litert_model_test.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,41 @@ TEST(BenchmarkLiteRtModelTest, GetModelSizeFromPathSucceeded) {
7070
EXPECT_GE(listener.results_.model_size_mb(), 0);
7171
}
7272

73+
TEST(BenchmarkLiteRtModelTest, GPUAcceleration) {
74+
// MSAN does not support GPU tests.
75+
#if defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER)
76+
GTEST_SKIP() << "GPU tests are not supported In msan";
77+
#endif
78+
BenchmarkParams params = BenchmarkLiteRtModel::DefaultParams();
79+
params.Set<std::string>("graph", kModelPath);
80+
params.Set<std::string>("signature_to_run_for", kSignatureToRunFor);
81+
params.Set<bool>("use_cpu", false);
82+
params.Set<bool>("use_gpu", true);
83+
params.Set<bool>("require_full_delegation", true);
84+
85+
BenchmarkLiteRtModel benchmark = BenchmarkLiteRtModel(std::move(params));
86+
87+
EXPECT_EQ(benchmark.Run(), kTfLiteOk);
88+
}
89+
90+
TEST(BenchmarkLiteRtModelTest, GPUAccelerationWithProfiler) {
91+
// MSAN does not support GPU tests.
92+
#if defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER)
93+
GTEST_SKIP() << "GPU tests are not supported In msan";
94+
#endif
95+
BenchmarkParams params = BenchmarkLiteRtModel::DefaultParams();
96+
params.Set<std::string>("graph", kModelPath);
97+
params.Set<std::string>("signature_to_run_for", kSignatureToRunFor);
98+
params.Set<bool>("use_cpu", false);
99+
params.Set<bool>("use_gpu", true);
100+
params.Set<bool>("require_full_delegation", true);
101+
params.Set<bool>("use_profiler", true);
102+
103+
BenchmarkLiteRtModel benchmark = BenchmarkLiteRtModel(std::move(params));
104+
105+
EXPECT_EQ(benchmark.Run(), kTfLiteOk);
106+
}
107+
73108
TEST(BenchmarkLiteRtModelTest, BenchmarkWithResultFilePath) {
74109
BenchmarkParams params = BenchmarkLiteRtModel::DefaultParams();
75110
params.Set<std::string>("graph", kModelPath);

0 commit comments

Comments
 (0)