fixstars / ion-kit

Modernized graph-based data processing framework
MIT License
7 stars 6 forks source link

Consistent Python Binding implementation along C++ #206

Closed Fixstars-momoko closed 8 months ago

Fixstars-momoko commented 8 months ago

1. The type of Param Value along C++

ion-kit 1.0.0 takes int/boolean/double value for Params of BB, but Python binding takes only string

e.g.

C++

...
      .set_param(
        Param("num_devices", num_device),
        Param("frame_sync", true),
        Param("realtime_diaplay_mode", false)
      );

Python

# set params
num_devices = Param('num_devices', str(num_device))
pixel_format_ptr = Param('realtime_diaplay_mode', 'true')
frame_sync = Param('frame_sync', 'false')

We would like to make Python API look like:

Python

# set params
num_devices = Param('num_devices', num_device)
pixel_format_ptr = Param('realtime_diaplay_mode', True)
frame_sync = Param('frame_sync', False)

2. Allow Vector/List to bind

ion-kit 1.0.0 allows users to bind vector of buffer as follows:

C++

std::vector< int > buf_size = std::vector < int >{ width, height };
    if (pixel_format == "RGB8"){
        buf_size.push_back(3);
    }
    std::vector<Halide::Buffer<T>> output;
    for (int i = 0; i < num_device; ++i){
      output.push_back(Halide::Buffer<T>(buf_size));
    }
    n["output"].bind(output);

However, python version does not allow to bind (port-map) from multiple output in a single port to List of Buffers, so we have to do one by one as follows by accessing the index:

Python

    # create halide buffer for output port
    outputs = []
    output_size = (width, height, )
    if pixelformat == "RGB8":
        output_size += (3,)
    outputs.append(Buffer(Type(TypeCode.Uint, depth_of_buffer, 1), output_size))

    # set I/O ports
    output_p[0].bind(outputs[0])

We want to allow user to bind from multiple output to List of buffer.

xinyuli1204 commented 8 months ago

https://github.com/fixstars/ion-kit/pull/207