aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/call_inliner.h
diff options
context:
space:
mode:
authorGravatar Chris Leary <leary@google.com>2017-07-27 23:36:58 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-07-27 23:40:41 -0700
commit560f0d22797ddeb66e8c35fc1c6e24c822ad64e2 (patch)
tree6fcd22896d9f4230bd8f52d3810ae7dcd5ca0a8d /tensorflow/compiler/xla/service/call_inliner.h
parent446450369b9f4375cf26c1c1bc3b9a3fd93059f5 (diff)
[XLA] Create CallInliner HLO pass to recursively force-inline kCall operations.
PiperOrigin-RevId: 163436255
Diffstat (limited to 'tensorflow/compiler/xla/service/call_inliner.h')
-rw-r--r--tensorflow/compiler/xla/service/call_inliner.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/call_inliner.h b/tensorflow/compiler/xla/service/call_inliner.h
new file mode 100644
index 0000000000..8647edffa7
--- /dev/null
+++ b/tensorflow/compiler/xla/service/call_inliner.h
@@ -0,0 +1,48 @@
+/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+#ifndef TENSORFLOW_COMPILER_XLA_SERVICE__CALL_INLINER_H_
+#define TENSORFLOW_COMPILER_XLA_SERVICE__CALL_INLINER_H_
+
+#include <deque>
+
+#include "tensorflow/compiler/xla/service/hlo_pass_interface.h"
+#include "tensorflow/compiler/xla/statusor.h"
+
+namespace xla {
+
+// For every kCall operation in the main computation, we inline the body of the
+// called function, and proceed recursively.
+class CallInliner : public HloPassInterface {
+ public:
+ ~CallInliner() override = default;
+ tensorflow::StringPiece name() const override { return "CallInliner"; }
+
+ StatusOr<bool> Run(HloModule* module) override;
+
+ private:
+ // Replaces the given call operation -- which must be an operation inside the
+ // entry computation with opcode kCall -- with the called computation's body,
+ // such that the called computation is inline in the entry computation.
+ //
+ // On successful inlining, the inlined computation may have itself contained
+ // calls; if so, they are added to the work_queue.
+ Status ReplaceWithInlinedBody(HloInstruction* call,
+ std::deque<HloInstruction*>* work_queue);
+};
+
+} // namespace xla
+
+#endif // TENSORFLOW_COMPILER_XLA_SERVICE__CALL_INLINER_H_