Skip to content

Commit efe57a2

Browse files
Matt-HurdGoogle-ML-Automation
authored andcommitted
[xprof] Add support for tracemark_lower and tracemark_upper profiler options
PiperOrigin-RevId: 816343394
1 parent 450be22 commit efe57a2

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

third_party/tsl/tsl/profiler/protobuf/profiler_options.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ message ProfileOptions {
7575
TraceOptions trace_options = 11;
7676

7777
// AdvancedConfigValue represents the configuration value, it can be one of
78-
// the following types: string, bool, int64, depending upon the config type.
78+
// the following types: string, bool, int64, int32, depending upon the config
79+
// type.
7980
message AdvancedConfigValue {
8081
oneof value {
8182
string string_value = 1;
8283
bool bool_value = 2;
8384
int64 int64_value = 3;
85+
int32 int32_value = 4;
8486
}
8587
}
8688

xla/tsl/profiler/utils/profiler_options_util.cc

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

26-
std::optional<std::variant<std::string, bool, int64_t>> GetConfigValue(
26+
std::optional<std::variant<std::string, bool, int64_t, int32_t>> GetConfigValue(
2727
const tensorflow::ProfileOptions& options, const std::string& key) {
2828
auto config = options.advanced_configuration().find(key);
2929

@@ -36,6 +36,8 @@ std::optional<std::variant<std::string, bool, int64_t>> GetConfigValue(
3636
return config_value.bool_value();
3737
} else if (config_value.has_int64_value()) {
3838
return config_value.int64_value();
39+
} else if (config_value.has_int32_value()) {
40+
return config_value.int32_value();
3941
}
4042
}
4143

xla/tsl/profiler/utils/profiler_options_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace tsl {
3232
namespace profiler {
3333
// Get config value from the profiler options, if the key is not found, return
3434
// std::nullopt.
35-
std::optional<std::variant<std::string, bool, int64_t>> GetConfigValue(
35+
std::optional<std::variant<std::string, bool, int64_t, int32_t>> GetConfigValue(
3636
const tensorflow::ProfileOptions& options, const std::string& key);
3737

3838
template <typename T>

xla/tsl/profiler/utils/session_manager.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ RemoteProfilerSessionManagerOptions GetRemoteSessionManagerOptionsLocked(
143143
options.mutable_profiler_options()->set_session_id(value);
144144
},
145145
nullptr);
146+
} else if (key == "tracemark_lower") {
147+
SetOption<int>(
148+
key, kw.second,
149+
[](tensorflow::ProfileOptions* options, int value) {
150+
options->mutable_advanced_configuration()->insert(
151+
{"tracemark_lower",
152+
tensorflow::ProfileOptions::AdvancedConfigValue()});
153+
options->mutable_advanced_configuration()
154+
->at("tracemark_lower")
155+
.set_int32_value(value);
156+
},
157+
options.mutable_profiler_options());
158+
} else if (key == "tracemark_upper") {
159+
SetOption<int>(
160+
key, kw.second,
161+
[](tensorflow::ProfileOptions* options, int value) {
162+
options->mutable_advanced_configuration()->insert(
163+
{"tracemark_upper",
164+
tensorflow::ProfileOptions::AdvancedConfigValue()});
165+
options->mutable_advanced_configuration()
166+
->at("tracemark_upper")
167+
.set_int32_value(value);
168+
},
169+
options.mutable_profiler_options());
146170
} else {
147171
LOG(WARNING) << "Unrecognised key: " << key;
148172
}

0 commit comments

Comments
 (0)