Update the regular expression checking TF op names.
PiperOrigin-RevId: 352110819 Change-Id: Ia34185927518a495e72bf810af1856f5068ec8b1
This commit is contained in:
parent
569a996c09
commit
a756df5df1
@ -42,7 +42,8 @@ const absl::string_view kMemcpyHToDOp = "MemcpyHToD";
|
||||
const absl::string_view kMemcpyDToHOp = "MemcpyDToH";
|
||||
|
||||
bool IsTfOpName(absl::string_view op_name) {
|
||||
static const LazyRE2 kTfOpNameRegEx = {"[A-Za-z0-9.][A-Za-z0-9_./]*"};
|
||||
// TODO(b/177602927): Confirm the naming convention with the TF team.
|
||||
static const LazyRE2 kTfOpNameRegEx = {"[A-Za-z0-9.][A-Za-z0-9_.\\/>-]*"};
|
||||
return RE2::FullMatch(op_name, *kTfOpNameRegEx);
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,18 @@ TEST(TfOpUtilsTest, OpWithoutTypeTest) {
|
||||
EXPECT_EQ(TfOpEventName(kName), "OpName"); // without trailing ':'
|
||||
}
|
||||
|
||||
TEST(TfOpUtilsTest, NameScopeTest) {
|
||||
const absl::string_view kName = "scope-1/scope2/OpName:OpType";
|
||||
TfOp tf_op = ParseTfOpFullname(kName);
|
||||
EXPECT_EQ(tf_op.category, Category::kTensorFlow);
|
||||
EXPECT_EQ(tf_op.name, "scope-1/scope2/OpName");
|
||||
EXPECT_EQ(tf_op.type, "OpType");
|
||||
std::vector<absl::string_view> name_scopes = ParseTfNameScopes(tf_op);
|
||||
EXPECT_EQ(name_scopes.size(), 2);
|
||||
EXPECT_EQ(name_scopes[0], "scope-1");
|
||||
EXPECT_EQ(name_scopes[1], "scope2");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace profiler
|
||||
} // namespace tensorflow
|
||||
|
Loading…
Reference in New Issue
Block a user