MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Profile

Function Profile

tensorflow/core/profiler/rpc/client/capture_profile.cc:90–128  ·  view source on GitHub ↗

Returns whether the returned trace is empty. Failure are handled by CHECK, i.e. abort()

Source from the content-addressed store, hash-verified

88// Returns whether the returned trace is empty.
89// Failure are handled by CHECK, i.e. abort()
90Status Profile(const string& service_addr, const string& logdir,
91 int duration_ms, const string& repository_root,
92 const string& session_id, const ProfileOptions& opts) {
93 ProfileRequest request =
94 PopulateProfileRequest(duration_ms, repository_root, session_id, opts);
95
96 ::grpc::ClientContext context;
97 ::grpc::ChannelArguments channel_args;
98 // TODO(qiuminxu): use `NewHostPortGrpcChannel` instead once their
99 // `ValidateHostPortPair` checks for empty host string case.
100 channel_args.SetInt(GRPC_ARG_MAX_MESSAGE_LENGTH,
101 std::numeric_limits<int32>::max());
102 std::unique_ptr<grpc::ProfilerService::Stub> stub =
103 grpc::ProfilerService::NewStub(::grpc::CreateCustomChannel(
104 "dns:///" + service_addr, ::grpc::InsecureChannelCredentials(),
105 channel_args));
106 ProfileResponse response;
107 TF_RETURN_IF_ERROR(
108 FromGrpcStatus(stub->Profile(&context, request, &response)));
109
110 if (!response.encoded_trace().empty()) {
111 TF_CHECK_OK(WriteTensorboardTPUProfile(logdir, session_id, "", response,
112 &std::cout));
113 // Print this at the end so that it's not buried in irrelevant LOG messages.
114 std::cout
115 << "NOTE: using the trace duration " << duration_ms << "ms."
116 << std::endl
117 << "Set an appropriate duration (with --duration_ms) if you "
118 "don't see a full step in your trace or the captured trace is too "
119 "large."
120 << std::endl;
121 }
122
123 if (response.encoded_trace().empty()) {
124 return Status(tensorflow::error::Code::UNAVAILABLE,
125 "No trace event is collected");
126 }
127 return Status::OK();
128}
129
130// Start a new profiling session that include all the hosts included in
131// hostnames, for the time interval of duration_ms. Possibly save the profiling

Callers 1

StartTracingFunction · 0.70

Calls 7

PopulateProfileRequestFunction · 0.85
FromGrpcStatusFunction · 0.85
maxFunction · 0.50
StatusClass · 0.50
ProfileMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected