| 2241 | } |
| 2242 | |
| 2243 | Status LayoutOptimizer::Optimize(Cluster* cluster, const GrapplerItem& item, |
| 2244 | GraphDef* output) { |
| 2245 | if (cluster == nullptr) { |
| 2246 | LOG(WARNING) << "layout optimizer was called with cluster == nullptr"; |
| 2247 | return errors::Aborted("cluster == nullptr."); |
| 2248 | } |
| 2249 | if (GetNumGPUs(*cluster) < 1) { |
| 2250 | return errors::Aborted( |
| 2251 | "No GPUs found: LayoutOptimizer is currently only tuned for GPU."); |
| 2252 | } |
| 2253 | |
| 2254 | GraphProperties graph_properties(item); |
| 2255 | TF_RETURN_IF_ERROR( |
| 2256 | graph_properties.InferStatically(/*assume_valid_feeds=*/false, |
| 2257 | /*aggressive_shape_inference=*/false, |
| 2258 | /*include_tensor_values=*/false)); |
| 2259 | GRAPPLER_RETURN_IF_DEADLINE_EXCEEDED(); |
| 2260 | |
| 2261 | virtual_placer_.reset(new VirtualPlacer(cluster->GetDevices())); |
| 2262 | nodes_to_preserve_ = item.NodesToPreserve(); |
| 2263 | |
| 2264 | TuningConfig config; |
| 2265 | config.no_gemm = true; |
| 2266 | // TODO(yaozhang): Enable tuning with various TuningConfig choices with |
| 2267 | // the measurement-based estimator. |
| 2268 | Status status = Tune(item, graph_properties, config, output); |
| 2269 | if (!status.ok()) { |
| 2270 | *output = item.graph; |
| 2271 | } |
| 2272 | return status; |
| 2273 | } |
| 2274 | |
| 2275 | void LayoutOptimizer::Feedback(Cluster* cluster, const GrapplerItem& item, |
| 2276 | const GraphDef& optimize_output, double result) { |
no test coverage detected