提交 43b04314 编写于 作者: T Tong Shen 提交者: TensorFlower Gardener

Move ParseHostComputeCore to side_effect_util.cc. No functionality change.

PiperOrigin-RevId: 216748472
上级 3fd902b2
......@@ -662,5 +662,6 @@ cc_library(
hdrs = ["side_effect_util.h"],
deps = [
"//tensorflow/core:core_cpu",
"@com_google_absl//absl/strings",
],
)
......@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/compiler/tf2xla/side_effect_util.h"
#include "absl/strings/numbers.h"
#include "tensorflow/core/graph/algorithm.h"
namespace tensorflow {
......@@ -64,4 +65,28 @@ bool HasSideEffectingNodes(const Graph& g) {
return false;
}
Status ParseHostComputeCoreList(absl::Span<const string> list_from_attr,
std::map<string, int>* host_compute_core) {
for (const auto& hc_core : list_from_attr) {
std::vector<string> parts = str_util::Split(hc_core, ":");
if (parts.size() != 2) {
return errors::InvalidArgument(
"Malformed host_compute_core entry ", hc_core,
" should be <cluster_name>:<core_number>.");
}
int core;
if (!absl::numbers_internal::safe_strto32_base(parts[1], &core, 10)) {
return errors::InvalidArgument("Malformed host_compute_core entry ",
hc_core,
" part after ':' should be an integer.");
}
if (host_compute_core->find(parts[0]) != host_compute_core->end()) {
return errors::InvalidArgument(
"Duplicate host_compute_core entry for cluster ", parts[0]);
}
(*host_compute_core)[parts[0]] = core;
}
return Status::OK();
}
} // namespace tensorflow
......@@ -42,6 +42,12 @@ std::set<std::string> CalculateTokenInputsForOutputToken(const Graph& g);
// Returns whether a graph contains side-effecting nodes.
bool HasSideEffectingNodes(const Graph& g);
// Parse the mapping from outside_compilation_subgraph name to core number,
// which is specified in an attr as a list of strings
// <subgraph_name>:<core_index>.
Status ParseHostComputeCoreList(absl::Span<const string> list_from_attr,
std::map<string, int>* host_compute_core);
} // namespace tensorflow
#endif // TENSORFLOW_COMPILER_TF2XLA_SIDE_EFFECT_UTIL_H_
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册