Add TF_CONST_INIT macro

Use instead of ABSL_CONST_INIT

PiperOrigin-RevId: 335878220
Change-Id: I3160bac33b55d2d64840b7bbb47c68b9f0bbeec5
This commit is contained in:
Jose Baiocchi 2020-10-07 08:53:59 -07:00 committed by TensorFlower Gardener
parent f61a5fd362
commit 7d7752d0a7
7 changed files with 38 additions and 22 deletions

View File

@ -93,6 +93,15 @@ limitations under the License.
#define TF_ATTRIBUTE_ANNOTATE(str)
#endif
// A variable declaration annotated with the `TF_CONST_INIT` attribute will
// not compile (on supported platforms) unless the variable has a constant
// initializer.
#if TF_HAS_CPP_ATTRIBUTE(clang::require_constant_initialization)
#define TF_CONST_INIT [[clang::require_constant_initialization]]
#else
#define TF_CONST_INIT
#endif
// Compilers can be told that a certain branch is not likely to be taken
// (for instance, a CHECK failure), and use that information in static
// analysis. Giving it this information can help it optimize for the

View File

@ -16,6 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_CORE_PROFILER_CONVERT_STEP_EVENTS_TO_STEPS_DB_H_
#define TENSORFLOW_CORE_PROFILER_CONVERT_STEP_EVENTS_TO_STEPS_DB_H_
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/protobuf/steps_db.pb.h"
#include "tensorflow/core/profiler/utils/event_span.h"
@ -23,7 +24,7 @@ limitations under the License.
namespace tensorflow {
namespace profiler {
ABSL_CONST_INIT extern const uint32 kDefaultGpuLocalCoreId;
TF_CONST_INIT extern const uint32 kDefaultGpuLocalCoreId;
// Converts from overlapped Step-Events to StepDatabaseResult.
StepDatabaseResult ConvertStepEventsToStepDb(

View File

@ -18,6 +18,7 @@ cc_library(
srcs = ["diagnostics.cc"],
hdrs = ["diagnostics.h"],
deps = [
"//tensorflow/core:lib",
"//tensorflow/core/profiler/protobuf:diagnostics_proto_cc",
"//tensorflow/core/profiler/protobuf:op_stats_proto_cc",
"//tensorflow/core/profiler/protobuf:steps_db_proto_cc",
@ -119,6 +120,7 @@ cc_library(
srcs = ["tf_op_utils.cc"],
hdrs = ["tf_op_utils.h"],
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:regexp_internal",
"@com_google_absl//absl/strings",
],

View File

@ -17,6 +17,7 @@ limitations under the License.
#define TENSORFLOW_CORE_PROFILER_UTILS_ERRORS_H_
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/profiler/protobuf/diagnostics.pb.h"
#include "tensorflow/core/profiler/protobuf/op_stats.pb.h"
@ -24,15 +25,15 @@ namespace tensorflow {
namespace profiler {
// Error message that the visualization is based on incomplete step.
ABSL_CONST_INIT extern const absl::string_view kErrorIncompleteStep;
TF_CONST_INIT extern const absl::string_view kErrorIncompleteStep;
// Error message that no step marker is seen and visualization contains no
// step info.
ABSL_CONST_INIT extern const absl::string_view kErrorNoStepMarker;
TF_CONST_INIT extern const absl::string_view kErrorNoStepMarker;
ABSL_CONST_INIT extern const absl::string_view kNoDeviceTraceCollected;
TF_CONST_INIT extern const absl::string_view kNoDeviceTraceCollected;
ABSL_CONST_INIT extern const absl::string_view kStepsDropped;
TF_CONST_INIT extern const absl::string_view kStepsDropped;
void PopulateStepDiagnostics(const OpStats& op_stats, Diagnostics* diag);

View File

@ -20,6 +20,7 @@ limitations under the License.
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/profiler/protobuf/op_metrics.pb.h"
@ -27,7 +28,7 @@ namespace tensorflow {
namespace profiler {
// The name of OpMetrics to represent the idle time.
ABSL_CONST_INIT extern const absl::string_view kIdle;
TF_CONST_INIT extern const absl::string_view kIdle;
// Helps build an op metrics database (borrowed).
// Enables fast lookup of existing ops and prevents the creation of duplicate

View File

@ -21,15 +21,16 @@ limitations under the License.
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "tensorflow/core/platform/macros.h"
namespace tensorflow {
namespace profiler {
// Special op types.
ABSL_CONST_INIT extern const absl::string_view kUnknownOp;
ABSL_CONST_INIT extern const absl::string_view kDatasetOp;
ABSL_CONST_INIT extern const absl::string_view kMemcpyHToDOp;
ABSL_CONST_INIT extern const absl::string_view kMemcpyDToHOp;
TF_CONST_INIT extern const absl::string_view kUnknownOp;
TF_CONST_INIT extern const absl::string_view kDatasetOp;
TF_CONST_INIT extern const absl::string_view kMemcpyHToDOp;
TF_CONST_INIT extern const absl::string_view kMemcpyDToHOp;
enum class Category {
kTensorFlow,

View File

@ -21,31 +21,32 @@ limitations under the License.
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace profiler {
// Name of XPlane that contains TraceMe events.
ABSL_CONST_INIT extern const absl::string_view kHostThreadsPlaneName;
TF_CONST_INIT extern const absl::string_view kHostThreadsPlaneName;
// Name prefix of XPlane that contains GPU events.
ABSL_CONST_INIT extern const absl::string_view kGpuPlanePrefix;
TF_CONST_INIT extern const absl::string_view kGpuPlanePrefix;
// Name of XPlane that contains CUPTI driver API generated events.
ABSL_CONST_INIT extern const absl::string_view kCuptiDriverApiPlaneName;
TF_CONST_INIT extern const absl::string_view kCuptiDriverApiPlaneName;
// Name of XPlane that contains profile metadata such as XLA debug info.
ABSL_CONST_INIT extern const absl::string_view kMetadataPlaneName;
TF_CONST_INIT extern const absl::string_view kMetadataPlaneName;
// Name of XPlane that contains kpi related metrics.
ABSL_CONST_INIT extern const absl::string_view kTFStreamzPlaneName;
TF_CONST_INIT extern const absl::string_view kTFStreamzPlaneName;
// Name of XPlane that contains events from python tracer.
ABSL_CONST_INIT extern const absl::string_view kPythonTracerPlaneName;
TF_CONST_INIT extern const absl::string_view kPythonTracerPlaneName;
// Names of XLines that contain ML-level events.
ABSL_CONST_INIT extern const absl::string_view kStepLineName;
ABSL_CONST_INIT extern const absl::string_view kTensorFlowNameScopeLineName;
ABSL_CONST_INIT extern const absl::string_view kTensorFlowOpLineName;
ABSL_CONST_INIT extern const absl::string_view kXlaModuleLineName;
ABSL_CONST_INIT extern const absl::string_view kXlaOpLineName;
ABSL_CONST_INIT extern const absl::string_view kKernelLaunchLineName;
TF_CONST_INIT extern const absl::string_view kStepLineName;
TF_CONST_INIT extern const absl::string_view kTensorFlowNameScopeLineName;
TF_CONST_INIT extern const absl::string_view kTensorFlowOpLineName;
TF_CONST_INIT extern const absl::string_view kXlaModuleLineName;
TF_CONST_INIT extern const absl::string_view kXlaOpLineName;
TF_CONST_INIT extern const absl::string_view kKernelLaunchLineName;
// Interesting event types (i.e., TraceMe names).
enum HostEventType {