| 2777 | } |
| 2778 | |
| 2779 | bool HloInstruction::IsFusible() const { |
| 2780 | // Instructions which are traced should not be fused. |
| 2781 | if (tracing()) { |
| 2782 | return false; |
| 2783 | } |
| 2784 | // Some kinds of instructions don't make sense to fuse. |
| 2785 | switch (opcode_) { |
| 2786 | case HloOpcode::kDomain: |
| 2787 | case HloOpcode::kParameter: |
| 2788 | case HloOpcode::kWhile: |
| 2789 | case HloOpcode::kConditional: |
| 2790 | case HloOpcode::kCall: |
| 2791 | return false; |
| 2792 | // Fusions are always fusible. |
| 2793 | case HloOpcode::kFusion: |
| 2794 | // Side effecting reduce and reduce window would be invalid HLO. |
| 2795 | case HloOpcode::kMap: |
| 2796 | case HloOpcode::kReduce: |
| 2797 | case HloOpcode::kReduceWindow: |
| 2798 | return true; |
| 2799 | // Side effecting instructions cannot be fused. |
| 2800 | default: |
| 2801 | return !HasSideEffect(); |
| 2802 | } |
| 2803 | } |
| 2804 | |
| 2805 | HloInstruction::HloInstruction(HloOpcode opcode, const Shape& shape) |
| 2806 | : unique_id_(-1), |
no outgoing calls
no test coverage detected