Skip to content

Commit cad0435

Browse files
Profiler Teamcopybara-github
authored andcommitted
Remove InputBoundRule and refactor input-bound check into SignalProvider.
PiperOrigin-RevId: 831477459
1 parent b9ee169 commit cad0435

File tree

7 files changed

+16
-78
lines changed

7 files changed

+16
-78
lines changed

xprof/convert/smart_suggestion/BUILD

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,10 @@ cc_library(
6565
],
6666
)
6767

68-
cc_library(
69-
name = "input_bound_rule",
70-
hdrs = ["input_bound_rule.h"],
71-
deps = [
72-
":signal_provider",
73-
":smart_suggestion_rule",
74-
"@com_google_absl//absl/status:statusor",
75-
"@org_xprof//plugin/xprof/protobuf:smart_suggestion_proto_cc",
76-
],
77-
)
78-
7968
cc_library(
8069
name = "host_processing_bound_rule",
8170
hdrs = ["host_processing_bound_rule.h"],
8271
deps = [
83-
":input_bound_rule",
8472
":signal_provider",
8573
":smart_suggestion_rule",
8674
"@com_google_absl//absl/status:statusor",
@@ -95,7 +83,6 @@ cc_library(
9583
name = "data_transfer_bound_rule",
9684
hdrs = ["data_transfer_bound_rule.h"],
9785
deps = [
98-
":input_bound_rule",
9986
":signal_provider",
10087
":smart_suggestion_rule",
10188
"@com_google_absl//absl/status:statusor",
@@ -194,7 +181,6 @@ cc_library(
194181
":compute_bound_rule",
195182
":data_transfer_bound_rule",
196183
":host_processing_bound_rule",
197-
":input_bound_rule",
198184
":memory_bound_rule",
199185
":smart_suggestion_rule_factory",
200186
":sparse_core_bound_rule",

xprof/convert/smart_suggestion/all_rules.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ limitations under the License.
2020
#include "xprof/convert/smart_suggestion/compute_bound_rule.h"
2121
#include "xprof/convert/smart_suggestion/data_transfer_bound_rule.h"
2222
#include "xprof/convert/smart_suggestion/host_processing_bound_rule.h"
23-
#include "xprof/convert/smart_suggestion/input_bound_rule.h"
2423
#include "xprof/convert/smart_suggestion/memory_bound_rule.h"
2524
#include "xprof/convert/smart_suggestion/smart_suggestion_rule_factory.h"
2625
#include "xprof/convert/smart_suggestion/sparse_core_bound_rule.h"
@@ -36,7 +35,6 @@ inline void RegisterAllRules(SmartSuggestionRuleFactory* f) {
3635
f->Register<ComputeBoundRule>();
3736
f->Register<DataTransferBoundRule>();
3837
f->Register<HostProcessingBoundRule>();
39-
f->Register<InputBoundRule>();
4038
f->Register<MemoryBoundRule>();
4139
f->Register<SparseCoreBoundRule>();
4240
f->Register<TensorCoreIdleBoundRule>();

xprof/convert/smart_suggestion/constants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ inline constexpr double kHbmUtilizationHighThreshold = 70.0;
3333
inline constexpr double kMxuUtilizationLowThreshold = 50.0;
3434
inline constexpr double kMxuUtilizationHighThreshold = 70.0;
3535

36+
// Thresholds for input percentage of step time for bottleneck classification.
37+
// If input percentage is higher than kInfeedPercentageThreshold, it is
38+
// considered input bound.
39+
inline constexpr double kInfeedPercentageThreshold = 10.0;
40+
3641
} // namespace profiler
3742
} // namespace tensorflow
3843

xprof/convert/smart_suggestion/data_transfer_bound_rule.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ limitations under the License.
2323
#include "absl/strings/str_cat.h"
2424
#include "absl/strings/str_format.h"
2525
#include "xla/tsl/platform/statusor.h"
26-
#include "xprof/convert/smart_suggestion/input_bound_rule.h"
2726
#include "xprof/convert/smart_suggestion/signal_provider.h"
2827
#include "xprof/convert/smart_suggestion/smart_suggestion_rule.h"
2928
#include "plugin/xprof/protobuf/smart_suggestion.pb.h"
@@ -40,8 +39,7 @@ constexpr double kDataTransferBoundThresholdInPercent = 30;
4039
class DataTransferBoundRule : public SmartSuggestionRule {
4140
protected:
4241
bool MeetsConditions(const SignalProvider& signal_provider) const override {
43-
InputBoundRule input_bound_rule;
44-
if (!input_bound_rule.MeetsConditions(signal_provider)) {
42+
if (!signal_provider.IsInputBound()) {
4543
return false;
4644
}
4745

xprof/convert/smart_suggestion/host_processing_bound_rule.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ limitations under the License.
2323
#include "absl/strings/str_cat.h"
2424
#include "absl/strings/str_format.h"
2525
#include "xla/tsl/platform/statusor.h"
26-
#include "xprof/convert/smart_suggestion/input_bound_rule.h"
2726
#include "xprof/convert/smart_suggestion/signal_provider.h"
2827
#include "xprof/convert/smart_suggestion/smart_suggestion_rule.h"
2928
#include "plugin/xprof/protobuf/smart_suggestion.pb.h"
@@ -41,8 +40,7 @@ constexpr double kHostProcessingBoundThresholdInPercent = 50;
4140
class HostProcessingBoundRule : public SmartSuggestionRule {
4241
protected:
4342
bool MeetsConditions(const SignalProvider& signal_provider) const override {
44-
InputBoundRule input_bound_rule;
45-
if (!input_bound_rule.MeetsConditions(signal_provider)) {
43+
if (!signal_provider.IsInputBound()) {
4644
return false;
4745
}
4846

xprof/convert/smart_suggestion/input_bound_rule.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

xprof/convert/smart_suggestion/signal_provider.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ class SignalProvider {
180180
*hbm_utilization < kHbmUtilizationLowThreshold;
181181
}
182182

183+
// Returns true if the input percentage of step time is above the threshold.
184+
bool IsInputBound() const {
185+
absl::StatusOr<double> input_percent = GetInputPercentOfStepTime();
186+
if (!input_percent.ok()) {
187+
return false;
188+
}
189+
return *input_percent > kInfeedPercentageThreshold;
190+
}
191+
183192
private:
184193
std::unique_ptr<ToolDataProvider> tool_data_provider_;
185194
};

0 commit comments

Comments
 (0)