1 /* Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #include "tensorflow/core/profiler/utils/tpu_xplane_utils.h" 16 17 #include <vector> 18 19 #include "tensorflow/core/platform/regexp.h" 20 #include "tensorflow/core/profiler/protobuf/xplane.pb.h" 21 #include "tensorflow/core/profiler/utils/xplane_schema.h" 22 #include "tensorflow/core/profiler/utils/xplane_utils.h" 23 24 namespace tensorflow { 25 namespace profiler { 26 FindTensorCorePlanes(const XSpace & xspace)27std::vector<const XPlane*> FindTensorCorePlanes(const XSpace& xspace) { 28 return FindPlanes(xspace, [](const XPlane& xplane) { 29 static const LazyRE2 re = {kTpuPlaneRegex}; 30 return RE2::FullMatch(xplane.name(), *re); 31 }); 32 } 33 FindMutableTensorCorePlanes(XSpace * xspace)34std::vector<XPlane*> FindMutableTensorCorePlanes(XSpace* xspace) { 35 return FindMutablePlanes(xspace, [](const XPlane& xplane) { 36 static const LazyRE2 re = {kTpuPlaneRegex}; 37 return RE2::FullMatch(xplane.name(), *re); 38 }); 39 } 40 41 } // namespace profiler 42 } // namespace tensorflow 43