it ran without crashing!

This commit is contained in:
Nicholas Young 2024-10-14 19:12:51 -07:00
parent 89370b7ff2
commit 61597754a9

View file

@ -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 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: hlo.hailo_configured_network_group = undefined;
var network_group_size : usize = 1; var network_group_size : usize = 1;
const input_vstream_params : [max_edge_layers]hlo.hailo_input_vstream_params_by_name_t = undefined; var 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; var 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; var output_vstreams : [max_edge_layers]hlo.hailo_output_vstream = undefined;
const input_vstreams : [max_edge_layers]hlo.hailo_input_vstream = undefined; var input_vstreams : [max_edge_layers]hlo.hailo_input_vstream = undefined;
var input_vstream_size : usize = max_edge_layers; var input_vstream_size : usize = max_edge_layers;
var output_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); status = hlo.hailo_init_configure_params_by_vdevice(hef, vdevice, &config_params);
assert(status == hlo.HAILO_SUCCESS); 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", .{}); std.debug.print("Init configure params complete\n", .{});
assert(vdevice != null); assert(vdevice != null);
@ -65,29 +64,39 @@ pub fn main() void {
assert(status == hlo.HAILO_SUCCESS); assert(status == hlo.HAILO_SUCCESS);
std.debug.print("Configure vdevice complete!\n", .{}); 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, status = hlo.hailo_make_input_vstream_params(network_group, false, hlo.HAILO_FORMAT_TYPE_AUTO,
@constCast(&input_vstream_params), &input_vstream_size); &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); 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, 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); assert(status == hlo.HAILO_SUCCESS);
std.debug.print("Output vstream params initialized\n", .{});
assert(input_vstream_size <= max_edge_layers); 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); 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); assert(status == hlo.HAILO_SUCCESS);
defer _ = hlo.hailo_release_output_vstreams(@constCast(&output_vstreams), output_vstream_size); std.debug.print("Output vstreams initialized\n", .{});
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 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); // write_to_hlo(_, alloc);