diff --git a/src/main.zig b/src/main.zig index 6f7f7a3..e8caeb0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -29,10 +29,10 @@ pub fn main() void { var config_params: hlo.hailo_configure_params_t = undefined; // std.mem.zeroInit(hlo.hailo_vdevice_params_t, .{}); var network_group: hlo.hailo_configured_network_group = undefined; var network_group_size : usize = 1; - const input_vstream_params : [max_edge_layers]hlo.hailo_input_vstream_params_by_name_t = undefined; - const output_vstream_params : [max_edge_layers]hlo.hailo_output_vstream_params_by_name_t = undefined; - const output_vstreams : [max_edge_layers]hlo.hailo_output_vstream = undefined; - const input_vstreams : [max_edge_layers]hlo.hailo_input_vstream = undefined; + var input_vstream_params : [max_edge_layers]hlo.hailo_input_vstream_params_by_name_t = undefined; + var output_vstream_params : [max_edge_layers]hlo.hailo_output_vstream_params_by_name_t = undefined; + var output_vstreams : [max_edge_layers]hlo.hailo_output_vstream = undefined; + var input_vstreams : [max_edge_layers]hlo.hailo_input_vstream = undefined; var input_vstream_size : usize = max_edge_layers; var output_vstream_size : usize = max_edge_layers; @@ -52,7 +52,6 @@ pub fn main() void { status = hlo.hailo_init_configure_params_by_vdevice(hef, vdevice, &config_params); assert(status == hlo.HAILO_SUCCESS); - std.debug.print("Size of network_group: {any}\n", .{ @sizeOf(hlo.hailo_configured_network_group) }); std.debug.print("Init configure params complete\n", .{}); assert(vdevice != null); @@ -65,29 +64,39 @@ pub fn main() void { assert(status == hlo.HAILO_SUCCESS); std.debug.print("Configure vdevice complete!\n", .{}); + std.debug.print("And your network group iiiiisssss: '{any}'\n", .{ network_group }); - status = hlo.hailo_make_input_vstream_params(network_group, true, hlo.HAILO_FORMAT_TYPE_AUTO, - @constCast(&input_vstream_params), &input_vstream_size); + status = hlo.hailo_make_input_vstream_params(network_group, false, hlo.HAILO_FORMAT_TYPE_AUTO, + &input_vstream_params[0], &input_vstream_size); + // What in the world. I guess that's what happens when C uses start-base pointers for arrays assert(status == hlo.HAILO_SUCCESS); + std.debug.print("Input vstream params initialized\n", .{}); + status = hlo.hailo_make_output_vstream_params(network_group, true, hlo.HAILO_FORMAT_TYPE_AUTO, - @constCast(&output_vstream_params), &output_vstream_size); + &output_vstream_params[0], &output_vstream_size); assert(status == hlo.HAILO_SUCCESS); + std.debug.print("Output vstream params initialized\n", .{}); + assert(input_vstream_size <= max_edge_layers); - status = hlo.hailo_create_input_vstreams(network_group, @constCast(&input_vstream_params), input_vstream_size, @constCast(&input_vstreams)); + status = hlo.hailo_create_input_vstreams(network_group, &input_vstream_params, input_vstream_size, &input_vstreams[0]); assert(status == hlo.HAILO_SUCCESS); - status = hlo.hailo_create_output_vstreams(network_group, @constCast(&output_vstream_params), output_vstream_size, @constCast(&output_vstreams)); + std.debug.print("Input vstreams initialized\n", .{}); + + status = hlo.hailo_create_output_vstreams(network_group, &output_vstream_params, output_vstream_size, &output_vstreams[0]); assert(status == hlo.HAILO_SUCCESS); - defer _ = hlo.hailo_release_output_vstreams(@constCast(&output_vstreams), output_vstream_size); - defer _ = hlo.hailo_release_input_vstreams(@constCast(&input_vstreams), input_vstream_size); - defer _ = hlo.hailo_release_hef(hef); - defer _ = hlo.hailo_release_vdevice(vdevice); + std.debug.print("Output vstreams initialized\n", .{}); - std.debug.print("output vstream size is: {any}", .{output_vstream_size}); + _ = hlo.hailo_release_output_vstreams(&output_vstreams, output_vstream_size); + _ = hlo.hailo_release_input_vstreams(&input_vstreams, input_vstream_size); + _ = hlo.hailo_release_hef(hef); + _ = hlo.hailo_release_vdevice(vdevice); + + std.debug.print("output vstream size is: {any}\n", .{output_vstream_size}); // write_to_hlo(_, alloc);