Skip to content

Commit 01e3710

Browse files
cky9301copybara-github
authored andcommitted
Change default pending shape func to a fixed code location instead of creating a lambda ad-hoc.
PiperOrigin-RevId: 720623081
1 parent 8f1893f commit 01e3710

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tsl/profiler/lib/scoped_memory_debug_annotation.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ limitations under the License.
1414
==============================================================================*/
1515
#include "tsl/profiler/lib/scoped_memory_debug_annotation.h"
1616

17+
#include <string>
18+
1719
namespace tsl {
1820
namespace profiler {
1921

22+
std::string DefaultPendingShapeFunc() { return ""; }
23+
2024
/*static*/ MemoryDebugAnnotation*
2125
ScopedMemoryDebugAnnotation::ThreadMemoryDebugAnnotation() {
2226
static thread_local MemoryDebugAnnotation annotation;

tsl/profiler/lib/scoped_memory_debug_annotation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ limitations under the License.
2323
namespace tsl {
2424
namespace profiler {
2525

26+
std::string DefaultPendingShapeFunc();
27+
2628
// Annotations for memory profiling and debugging purpose.
2729
// ScopedMemoryDebugAnnotation will cache the annotations in thread-local
2830
// memory, and some allocators will try to tag allocations with the annotations.
@@ -34,7 +36,7 @@ struct MemoryDebugAnnotation {
3436
// A lambda function, when invoked, it will generate the string that describe
3537
// the shape of the pending tensor. By default, the TensorShape string is an
3638
// empty string.
37-
std::function<std::string()> pending_shape_func = []() { return ""; };
39+
std::function<std::string()> pending_shape_func = DefaultPendingShapeFunc;
3840
};
3941

4042
// Wrapper class of MemoryDebugAnnotation for RAII.

0 commit comments

Comments
 (0)