Reduce, ReduceWindow, and SelectAndScatter ops may need a non-random initialization value.
| 477 | // Reduce, ReduceWindow, and SelectAndScatter ops may need a non-random |
| 478 | // initialization value. |
| 479 | bool NeedsInitValue(const HloUse& use) { |
| 480 | const HloInstruction* const instruction = use.instruction; |
| 481 | const HloOpcode opcode = instruction->opcode(); |
| 482 | const int64 op_num = use.operand_number; |
| 483 | return ((opcode == HloOpcode::kReduceWindow && op_num == 1) || |
| 484 | (opcode == HloOpcode::kSelectAndScatter && op_num == 2) || |
| 485 | (opcode == HloOpcode::kReduce && |
| 486 | op_num >= instruction->operand_count() / 2)); |
| 487 | } |
| 488 | |
| 489 | // Generate random values that are constrained to the input_shape minus the |
| 490 | // output_shape so as not to produce wrapping slices, for instance. |
no test coverage detected