| 710 | } |
| 711 | |
| 712 | XlaOp XlaBuilder::Parameter( |
| 713 | int64 parameter_number, const Shape& shape, const string& name, |
| 714 | const std::vector<bool>& replicated_at_leaf_buffers) { |
| 715 | return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { |
| 716 | HloInstructionProto instr; |
| 717 | if (!parameter_numbers_.insert(parameter_number).second) { |
| 718 | return InvalidArgument("parameter %d already registered", |
| 719 | parameter_number); |
| 720 | } |
| 721 | instr.set_parameter_number(parameter_number); |
| 722 | instr.set_name(name); |
| 723 | *instr.mutable_shape() = shape.ToProto(); |
| 724 | if (!replicated_at_leaf_buffers.empty()) { |
| 725 | auto replication = instr.mutable_parameter_replication(); |
| 726 | for (bool replicated : replicated_at_leaf_buffers) { |
| 727 | replication->add_replicated_at_leaf_buffers(replicated); |
| 728 | } |
| 729 | } |
| 730 | return AddInstruction(std::move(instr), HloOpcode::kParameter); |
| 731 | }); |
| 732 | } |
| 733 | |
| 734 | XlaOp XlaBuilder::Broadcast(XlaOp operand, |
| 735 | absl::Span<const int64> broadcast_sizes) { |
no test coverage detected