From f6c2f860868ba4c19c3bec78a049dcf3847b2f67 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Mon, 17 Oct 2022 11:46:04 -0700 Subject: [PATCH] Fix -Wunused-variable warnings Remove unused variables. Add __unused attribute to variable used in assert clause. Move variable to inside header guard when only used in header guard. PiperOrigin-RevId: 481699164 --- .../calculators/tensor/image_to_tensor_converter_metal.cc | 1 - mediapipe/calculators/tensor/inference_calculator_metal.cc | 3 --- mediapipe/calculators/tensor/tensor_converter_calculator.cc | 1 - .../calculators/tensor/tensors_to_detections_calculator.cc | 1 - mediapipe/calculators/tflite/tflite_converter_calculator.cc | 2 +- mediapipe/gpu/MPPGraphGPUData.mm | 3 ++- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc b/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc index cfabae33..f6c8b191 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_converter_metal.cc @@ -262,7 +262,6 @@ class SubRectExtractorMetal { RET_CHECK(pipeline_state != nil); std::string output_type_def; - MTLPixelFormat pixel_format; switch (output_format) { case OutputFormat::kF16C4: output_type_def = R"( diff --git a/mediapipe/calculators/tensor/inference_calculator_metal.cc b/mediapipe/calculators/tensor/inference_calculator_metal.cc index ff8ebe14..a85071f3 100644 --- a/mediapipe/calculators/tensor/inference_calculator_metal.cc +++ b/mediapipe/calculators/tensor/inference_calculator_metal.cc @@ -224,9 +224,6 @@ absl::Status InferenceCalculatorMetalImpl::InitInterpreter( void InferenceCalculatorMetalImpl::AddDelegate( CalculatorContext* cc, tflite::InterpreterBuilder* interpreter_builder) { - const auto& calculator_opts = - cc->Options(); - // Configure and create the delegate. TFLGpuDelegateOptions options; // `enable_quantization` enables the run of sparse models i.e. the models with diff --git a/mediapipe/calculators/tensor/tensor_converter_calculator.cc b/mediapipe/calculators/tensor/tensor_converter_calculator.cc index f3c7c7b0..0b750b85 100644 --- a/mediapipe/calculators/tensor/tensor_converter_calculator.cc +++ b/mediapipe/calculators/tensor/tensor_converter_calculator.cc @@ -296,7 +296,6 @@ absl::Status TensorConverterCalculator::ProcessGPU(CalculatorContext* cc) { output_tensors->emplace_back(Tensor::ElementType::kFloat32, Tensor::Shape{1, height, width, channels}); #if MEDIAPIPE_METAL_ENABLED - id device = gpu_helper_.mtlDevice; id command_buffer = [gpu_helper_ commandBuffer]; command_buffer.label = @"TensorConverterCalculatorConvert"; id compute_encoder = diff --git a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc index 11c1341d..97ef01b4 100644 --- a/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc +++ b/mediapipe/calculators/tensor/tensors_to_detections_calculator.cc @@ -532,7 +532,6 @@ absl::Status TensorsToDetectionsCalculator::ProcessGPU( detection_classes.data(), output_detections)); #elif MEDIAPIPE_METAL_ENABLED - id device = gpu_helper_.mtlDevice; if (!anchors_init_) { if (input_tensors.size() == kNumInputTensorsWithAnchors) { RET_CHECK_EQ(input_tensors.size(), kNumInputTensorsWithAnchors); diff --git a/mediapipe/calculators/tflite/tflite_converter_calculator.cc b/mediapipe/calculators/tflite/tflite_converter_calculator.cc index d9dfd152..f2a2f68b 100644 --- a/mediapipe/calculators/tflite/tflite_converter_calculator.cc +++ b/mediapipe/calculators/tflite/tflite_converter_calculator.cc @@ -499,7 +499,6 @@ absl::Status TfLiteConverterCalculator::InitGpu(CalculatorContext* cc) { gpu_data_out_ = absl::make_unique(); gpu_data_out_->elements = input.height() * input.width() * max_num_channels_; const bool include_alpha = (max_num_channels_ == 4); - const bool single_channel = (max_num_channels_ == 1); if (!(format == mediapipe::ImageFormat::GRAY8 || format == mediapipe::ImageFormat::SRGB || format == mediapipe::ImageFormat::SRGBA)) @@ -509,6 +508,7 @@ absl::Status TfLiteConverterCalculator::InitGpu(CalculatorContext* cc) { #endif // MEDIAPIPE_TFLITE_GPU_SUPPORTED #if MEDIAPIPE_TFLITE_GL_INFERENCE + const bool single_channel = (max_num_channels_ == 1); MP_RETURN_IF_ERROR(gpu_helper_.RunInGlContext( [this, &include_alpha, &input, &single_channel]() -> absl::Status { // Device memory. diff --git a/mediapipe/gpu/MPPGraphGPUData.mm b/mediapipe/gpu/MPPGraphGPUData.mm index 001d4e88..8ac1eefa 100644 --- a/mediapipe/gpu/MPPGraphGPUData.mm +++ b/mediapipe/gpu/MPPGraphGPUData.mm @@ -111,7 +111,8 @@ typedef CVOpenGLESTextureCacheRef CVTextureCacheType; - (CVMetalTextureCacheRef)mtlTextureCache { @synchronized(self) { if (!_mtlTextureCache) { - CVReturn err = CVMetalTextureCacheCreate(NULL, NULL, self.mtlDevice, NULL, &_mtlTextureCache); + CVReturn __unused err = + CVMetalTextureCacheCreate(NULL, NULL, self.mtlDevice, NULL, &_mtlTextureCache); NSAssert(err == kCVReturnSuccess, @"Error at CVMetalTextureCacheCreate %d", err); // TODO: register and flush metal caches too. }