From dadbec4cabca0d8fa020a655b21e41adb957587c Mon Sep 17 00:00:00 2001
From: Juhyun Lee <impjdi@google.com>
Date: Tue, 13 Aug 2019 12:30:09 -0700
Subject: [PATCH] Skip shared variables for
 VariableAccessor::GetConstDeclarations().

PiperOrigin-RevId: 263191156
---
 .../lite/delegates/gpu/gl/compiler/variable_accessor.cc   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.cc b/tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.cc
index e4dc75eef6e..9bac6d62a62 100644
--- a/tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.cc
+++ b/tensorflow/lite/delegates/gpu/gl/compiler/variable_accessor.cc
@@ -371,10 +371,16 @@ std::string VariableAccessor::GetConstDeclarations() const {
   // with index.
   std::string declarations;
   for (const auto& variable : name_to_variable_) {
+    // Skip shared variables.
+    const std::string& variable_name = variable.second.name;
+    if (shared_variables_.find(variable_name) != shared_variables_.end()) {
+      continue;
+    }
+
     const auto& value = variable.second.value;
     if (IsVariableLength(value)) {
       absl::StrAppend(&declarations, "const ", GetVariableType(value), " ",
-                      variable.second.name, "[] = ");
+                      variable_name, "[] = ");
       GetValue(value, &declarations);
       absl::StrAppend(&declarations, ";\n");
     }