Beispiel #1
0
    def _build_broadcast_graph(self, broadcast_params_dict, broadcast_phase):
        """Build broadcast graph."""
        from mindspore.nn.wrap.cell_wrapper import _BroadCastCell

        _broadcast_net = _BroadCastCell(broadcast_params_dict.values())
        _broadcast_net.phase = broadcast_phase
        broadcasted_params = _broadcast_net()
        for param_name, param in zip(broadcast_params_dict.keys(),
                                     broadcasted_params):
            broadcast_params_dict[param_name].set_data(param)
Beispiel #2
0
def _build_broadcast_graph(broadcast_params_dict, broadcast_phase):
    """Build broadcast graph."""
    from mindspore.nn.wrap.cell_wrapper import _BroadCastCell

    if not broadcast_params_dict:
        broadcast_params_dict = {}
    broadcast_params = []
    for param in broadcast_params_dict.values():
        broadcast_params.append(Tensor(param.asnumpy()))
    _broadcast_net = _BroadCastCell(broadcast_params)
    _broadcast_net.phase = broadcast_phase
    broadcasted_params = _broadcast_net()
    for param_name, param in zip(broadcast_params_dict.keys(), broadcasted_params):
        broadcast_params_dict[param_name].set_data(param)