Back to results
US 11,960,866 B2Granted
Method and system for constructing compiler intermediate representations from TensorFlow graph
AssigneeHuawei Technologies Co., Ltd.
InventorsJack Lee, Kai-Ting Amy Wang
Life of this patent
Estimating the term…
Abstract
A method and system are provided to construct, from a TensorFlow graph, a common intermediate representation that can be converted to a plurality of compiler intermediate representations (IRs), which enables compiler optimization to be applied efficiently.
Claims19
A method comprising:
- receiving, by a processing system, a TensorFlow graph including one or more control flows;
- processing, by the processing system, the TensorFlow graph to extract control flows from the TensorFlow graph and storing the control flows in an extracted control flows data structure;
- applying, by the processing system, a recursive trace algorithm on outputs of the TensorFlow graph, the applying the recursive trace algorithm comprising recursively utilizing the extracted control flows data structure on the outputs of the TensorFlow graph to construct a common intermediate representation that expresses hierarchical control flows;
- removing, by the processing system, all forwarding nodes contained within a TensorFlow graph loop predicate and loop bodies;
- for each respective nested common intermediate representation branch within the TensorFlow graph loop predicate and the loop bodies, responsive to determining that the respective nested common intermediate representation branch has an empty branch predicate:
- transferring, by the processing system, all nodes within a common intermediate representation branch into TensorFlow graph loop or bodies containing a branch;
- and
- removing, by the processing system, the common intermediate representation branch from the TensorFlow graph loop predicate or the loop bodies;
- storing, by the processing system, a common intermediate representation loop corresponding to the TensorFlow graph loop in the extracted control flows data structure, wherein the common intermediate representation loop includes the TensorFlow graph loop predicate and the loop bodies;
- and
- constructing, by the processing system, one or more compiler intermediate representations from the common intermediate representation.
8 more elements
A non-transitory computer-readable medium storing computer-readable instructions which, when executed by a processing system, cause the processing system to perform operations including:
- receiving a TensorFlow graph including one or more control flows;
- processing the TensorFlow graph to extract control flows from the TensorFlow graph and storing the control flows in an extracted control flows data structure;
- applying a recursive trace algorithm on outputs of the TensorFlow graph, the applying the recursive trace algorithm comprising recursively utilizing the extracted control flows data structure on the outputs of the TensorFlow graph to construct a common intermediate representation that expresses hierarchical control flows;
- removing all forwarding nodes contained within a TensorFlow graph loop predicate and loop bodies;
- for each respective nested common intermediate representation branch within the TensorFlow graph loop predicate and the loop bodies, responsive to determining that the respective nested common intermediate representation branch has an empty branch predicate:
- transferring all nodes within a common intermediate representation branch into TensorFlow graph loop or bodies containing a branch;
- and
- removing the common intermediate representation branch from the TensorFlow graph loop predicate or the loop bodies;
- storing a common intermediate representation loop corresponding to the TensorFlow graph loop in the extracted control flows data structure, wherein the common intermediate representation loop includes the TensorFlow graph loop predicate and the loop bodies;
- and
- constructing one or more compiler intermediate representations from the common intermediate representation.
8 more elements
A processing system comprising:
- a memory storing instructions;
- and
- at least one processor in communication with the memory, the at least one processor configured, upon execution of the instructions, to perform the following steps:
- receiving a TensorFlow graph including one or more control flows;
- processing the TensorFlow graph to extract control flows from the TensorFlow graph and storing the control flows in an extracted control flows data structure;
- applying a recursive trace algorithm on outputs of the TensorFlow graph, the applying the recursive trace algorithm comprising:
- recursively utilizing the extracted control flows data structure, on the outputs of the TensorFlow graph, to construct a common intermediate representation that expresses hierarchical control flows;
- removing all forwarding nodes contained within a TensorFlow graph loop predicate and loop bodies;
- for each respective nested common intermediate representation branch within the TensorFlow graph loop predicate and the loop bodies, responsive to determining that the respective nested common intermediate representation branch has an empty branch predicate:
- transferring all nodes within a common intermediate representation branch into TensorFlow graph loop or bodies containing a branch;
- and
- removing the common intermediate representation branch from the TensorFlow graph loop predicate or the loop bodies;
- storing a common intermediate representation loop corresponding to the TensorFlow graph loop in the extracted control flows data structure, wherein the common intermediate representation loop includes the TensorFlow graph loop predicate and the loop bodies;
- and
- constructing one or more compiler intermediate representations from the common intermediate representation.
12 more elements
Dependencies are inferred from the claim text.