| 1922 | } |
| 1923 | |
| 1924 | Status MasterSession::DoPartialRun(CallOptions* opts, |
| 1925 | const RunStepRequestWrapper& req, |
| 1926 | MutableRunStepResponseWrapper* resp) { |
| 1927 | auto cleanup = gtl::MakeCleanup([this] { MarkRunCompletion(); }); |
| 1928 | const string& prun_handle = req.partial_run_handle(); |
| 1929 | RunState* run_state = nullptr; |
| 1930 | { |
| 1931 | mutex_lock l(mu_); |
| 1932 | auto it = partial_runs_.find(prun_handle); |
| 1933 | if (it == partial_runs_.end()) { |
| 1934 | return errors::InvalidArgument( |
| 1935 | "Must run PartialRunSetup before performing partial runs"); |
| 1936 | } |
| 1937 | run_state = it->second.get(); |
| 1938 | } |
| 1939 | // CollectiveOps are not supported in partial runs. |
| 1940 | if (req.options().experimental().collective_graph_key() != |
| 1941 | BuildGraphOptions::kNoCollectiveGraphKey) { |
| 1942 | return errors::InvalidArgument( |
| 1943 | "PartialRun does not support Collective ops. collective_graph_key " |
| 1944 | "must be kNoCollectiveGraphKey."); |
| 1945 | } |
| 1946 | |
| 1947 | // If this is the first partial run, initialize the PerStepState. |
| 1948 | if (!run_state->step_started) { |
| 1949 | run_state->step_started = true; |
| 1950 | PerStepState pss; |
| 1951 | |
| 1952 | const auto count = run_state->count; |
| 1953 | pss.collect_timeline = |
| 1954 | req.options().trace_level() == RunOptions::FULL_TRACE; |
| 1955 | pss.collect_rpcs = req.options().trace_level() == RunOptions::FULL_TRACE; |
| 1956 | pss.report_tensor_allocations_upon_oom = |
| 1957 | req.options().report_tensor_allocations_upon_oom(); |
| 1958 | |
| 1959 | // Build the cost model every 'build_cost_model_every' steps after skipping |
| 1960 | // an |
| 1961 | // initial 'build_cost_model_after' steps. |
| 1962 | const int64 build_cost_model_after = |
| 1963 | session_opts_.config.graph_options().build_cost_model_after(); |
| 1964 | const int64 build_cost_model_every = |
| 1965 | session_opts_.config.graph_options().build_cost_model(); |
| 1966 | pss.collect_costs = |
| 1967 | build_cost_model_every > 0 && |
| 1968 | ((count + 1 - build_cost_model_after) % build_cost_model_every == 0); |
| 1969 | pss.collect_partition_graphs = req.options().output_partition_graphs(); |
| 1970 | |
| 1971 | std::unique_ptr<ProfileHandler> ph = run_state->rcg->GetProfileHandler( |
| 1972 | run_state->step_id, count, req.options()); |
| 1973 | if (ph) { |
| 1974 | pss.collect_timeline = true; |
| 1975 | pss.collect_rpcs = ph->should_collect_rpcs(); |
| 1976 | } |
| 1977 | |
| 1978 | run_state->pss = std::move(pss); |
| 1979 | run_state->ph = std::move(ph); |
| 1980 | } |
| 1981 |
nothing calls this directly
no test coverage detected