1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_STATIC_SCHEDULE_H_ 17 #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_STATIC_SCHEDULE_H_ 18 19 #include <unordered_map> 20 21 #include "tensorflow/core/framework/node_def.pb.h" 22 #include "tensorflow/core/grappler/clusters/cluster.h" 23 #include "tensorflow/core/grappler/costs/cost_estimator.h" 24 #include "tensorflow/core/grappler/grappler_item.h" 25 26 namespace tensorflow { 27 namespace grappler { 28 29 // Compute the earliest time at which the execution of each node in the graph 30 // can complete. 31 // In our estimation, we ensure that each node takes at least one nanosecond to 32 // execute: therefore the execution times can be used to derive a topological 33 // ordering of the graph (at least as long as there is no loop in the graph). 34 Status EstimateEarliestExecutionTimes( 35 const GrapplerItem& item, const Cluster* cluster, 36 std::unordered_map<const NodeDef*, Costs::NanoSeconds>* execution_times); 37 38 // Compute the time by which the execution of each node must complete to ensure 39 // the subsequent nodes can still be executed by the times predicted by the 40 // EstimateEarliestExecutionTimes function. 41 Status EstimateRequiredTimes( 42 const GrapplerItem& item, const Cluster* cluster, 43 const std::unordered_map<const NodeDef*, Costs::NanoSeconds>& 44 execution_times, 45 std::unordered_map<const NodeDef*, Costs::NanoSeconds>* required_times); 46 47 } // namespace grappler 48 } // end namespace tensorflow 49 50 #endif // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_STATIC_SCHEDULE_H_ 51