Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace reshaping workaround with ReshapePorts #7

Closed
mathisrichter opened this issue Nov 22, 2021 · 1 comment
Closed

Replace reshaping workaround with ReshapePorts #7

mathisrichter opened this issue Nov 22, 2021 · 1 comment
Assignees
Labels
1-feature New feature or request

Comments

@mathisrichter
Copy link
Contributor

mathisrichter commented Nov 22, 2021

In the absence of ReshapePorts in Lava, we have implemented reshaping with dedicated Reshape Processes (ReshapeBool, ReshapeInt) and changed the implementation of the connect() function to insert these Processes:
Population (Source) -> ReshapeBool -> Dense -> ReshapeInt -> Population (Destination)

Once ReshapePorts are available, use them and remove the Reshape Processes.

  1. In connect.py, replace
    # make connections from the source port to the connections process
    # TODO (MR) workaround in absence of ReshapePorts
    con_ip = connections.s_in
    rs1 = ReshapeBool(shape_in=src_op.shape, shape_out=con_ip.shape)
    src_op.connect(rs1.s_in)
    rs1.s_out.connect(con_ip)

    # make connections from the connections process to the destination port
    # TODO (MR) workaround in absence of ReshapePorts
    con_op = connections.a_out
    rs2 = ReshapeInt(shape_in=con_op.shape, shape_out=dst_ip.shape)
    con_op.connect(rs2.s_in)
    rs2.s_out.connect(dst_ip)

by

    # make connections from the source port to the connections process
    src_op_flat = src_op.reshape(connections.in_ports.s_in.shape)
    src_op_flat.connect(connections.in_ports.s_in)

    # make connections from the connections process to the destination port
    con_op = connections.out_ports.a_out.reshape(dst_ip.shape)
    con_op.connect(dst_ip)
  1. In test_connect.py, replace
        # check whether 'source' is connected to 'connections'
        src_op = source.out_ports.s_out
        con_ip = connections.in_ports.s_in
        # TODO (MR): remove this after switching to Reshape ports
        rs1_op = src_op.get_dst_ports()[0].process.out_ports.s_out
        self.assertEqual(rs1_op.get_dst_ports(), [con_ip])
        self.assertEqual(con_ip.get_src_ports(), [rs1_op])

        # check whether 'connections' is connected to 'target'
        con_op = connections.out_ports.a_out
        dst_op = destination.in_ports.a_in
        # TODO (MR): remove this after switching to Reshape ports
        rs2_op = con_op.get_dst_ports()[0].process.out_ports.s_out
        self.assertEqual(rs2_op.get_dst_ports(), [dst_op])
        self.assertEqual(dst_op.get_src_ports(), [rs2_op])

by

        # check whether 'source' is connected to 'connections'
        src_op = source.out_ports.s_out
        con_ip = connections.in_ports.s_in
        self.assertEqual(src_op.get_dst_ports(), [con_ip])
        self.assertEqual(con_ip.get_src_ports(), [src_op])

        # check whether 'connections' is connected to 'target'
        con_op = connections.out_ports.a_out
        dst_op = destination.in_ports.a_in
        self.assertEqual(con_op.get_dst_ports(), [dst_op])
        self.assertEqual(dst_op.get_src_ports(), [con_op])
  1. Remove directories lava/lib/dnf/connect/reshape_* including all content.
@mathisrichter
Copy link
Contributor Author

Fixed by #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant