提交 3e2c1087 编写于 作者: J Jacques Pienaar 提交者: TensorFlower Gardener

Avoid using constant folding fallback hook concurrently

Ran into case where failed constant folds resulted in non-deterministic test
behavior (e.g., failed to fold unrelated op).

Need to dig into this a bit more.

PiperOrigin-RevId: 286299132
Change-Id: I290dade5fba0fd5b08dae4d696878b9196fc516d
上级 7c87c156
......@@ -625,6 +625,7 @@ cc_library(
"//tensorflow/c:tf_status",
"//tensorflow/c/eager:c_api",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/stream_executor",
"//tensorflow/stream_executor/lib",
"@llvm//:support",
......
......@@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/c/eager/c_api.h"
#include "tensorflow/c/tf_status.h"
#include "tensorflow/compiler/mlir/tensorflow/utils/eval_util.h"
#include "tensorflow/core/platform/mutex.h"
namespace mlir {
namespace TF {
......@@ -59,6 +60,10 @@ LogicalResult ConstantFoldFallbackHook(
inputs.push_back(input.cast<ElementsAttr>());
}
// Avoid overlapping folds with the same context.
// TODO(jpienaar): Avoid using global context & mutex here.
static auto* mu = new tensorflow::mutex();
tensorflow::mutex_lock l(*mu);
return tensorflow::EvaluateOperation(inst, inputs, ctx, &results);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册