Ejemplo n.º 1
0
static void
rows_reordered_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer new_order, RBDisplayPageMenu *menu)
{
	GtkTreePath *root;
	root = get_root_path (menu);
	if (root != NULL) {
		if (gtk_tree_path_compare (path, root) == 0)
			rebuild_menu (menu);

		gtk_tree_path_free (root);
	}
}
Ejemplo n.º 2
0
/**
 * Send a HSM request to Lustre, described in \param request.
 *
 * \param path	  Fullpath to the file to operate on.
 * \param request The request, allocated with llapi_hsm_user_request_alloc().
 *
 * \return 0 on success, an error code otherwise.
 */
int llapi_hsm_request(const char *path, const struct hsm_user_request *request)
{
	int rc;
	int fd;

	rc = get_root_path(WANT_FD, NULL, &fd, (char *)path, -1);
	if (rc)
		return rc;

	rc = ioctl(fd, LL_IOC_HSM_REQUEST, request);
	/* If error, save errno value */
	rc = rc ? -errno : 0;

	close(fd);
	return rc;
}
Ejemplo n.º 3
0
static int
path_menu_index (RBDisplayPageMenu *menu, GtkTreePath *path)
{
	GtkTreePath *root;
	GtkTreePath *compare;
	int depth;
	int *indices;
	int index;

	compare = gtk_tree_path_copy (path);
	if (gtk_tree_path_up (compare) == FALSE) {
		gtk_tree_path_free (compare);
		return -1;
	}

	if (gtk_tree_path_get_depth (compare) == 0) {
		gtk_tree_path_free (compare);
		return -1;
	}

	root = get_root_path (menu);
	if (root == NULL) {
		gtk_tree_path_free (compare);
		return -1;
	}

	if (gtk_tree_path_compare (compare, root) != 0) {
		gtk_tree_path_free (root);
		gtk_tree_path_free (compare);
		return -1;
	}

	indices = gtk_tree_path_get_indices_with_depth (path, &depth);
	index = count_items (menu, indices[depth-1]);
	gtk_tree_path_free (root);
	gtk_tree_path_free (compare);
	return index;
}
Ejemplo n.º 4
0
bool Application::is_correctly_installed()
{
    const char* root_path = get_root_path();
    return strlen(root_path) > 0;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    const std::string root_path = get_root_path();
    std::string proto_file;
    std::string model_file;
    std::string image_file;
    std::string save_name="save.jpg";
	const char * device=nullptr;

    int res;
    while( ( res=getopt(argc,argv,"p:m:i:hd:"))!= -1)
    {
        switch(res)
        {
            case 'p':
                proto_file=optarg;
                break;
            case 'm':
                model_file=optarg;
                break;
            case 'i':
                image_file=optarg;
                break;
			case 'd':
				device=optarg;
				break;
            case 'h':
                std::cout << "[Usage]: " << argv[0] << " [-h]\n"
                          << "   [-p proto_file] [-m model_file] [-i image_file]\n";
                return 0;
            default:
                break;
        }
    }



    const char *model_name = "mssd_300";
    if(proto_file.empty())
    {
        proto_file = root_path + DEF_PROTO;
        std::cout<< "proto file not specified,using "<<proto_file<< " by default\n";

    }
    if(model_file.empty())
    {
        model_file = root_path + DEF_MODEL;
        std::cout<< "model file not specified,using "<<model_file<< " by default\n";
    }
    if(image_file.empty())
    {
        image_file = root_path + DEF_IMAGE;
        std::cout<< "image file not specified,using "<<image_file<< " by default\n";
    }

    // init tengine
    init_tengine_library();
    if (request_tengine_version("0.1") < 0)
        return 1;
    if (load_model(model_name, "caffe", proto_file.c_str(), model_file.c_str()) < 0)
        return 1;
    std::cout << "load model done!\n";
   
    // create graph
    graph_t graph = create_runtime_graph("graph", model_name, NULL);
    if (!check_graph_valid(graph))
    {
        std::cout << "create graph0 failed\n";
        return 1;
    }

	if(device!=nullptr)
	{
		set_graph_device(graph,device);
	}

	//dump_graph(graph);

    // input
    int img_h = 300;
    int img_w = 300;
    int img_size = img_h * img_w * 3;
    float *input_data = (float *)malloc(sizeof(float) * img_size);

    int node_idx=0;
    int tensor_idx=0;
    tensor_t input_tensor = get_graph_input_tensor(graph, node_idx, tensor_idx);
    if(!check_tensor_valid(input_tensor))
    {
        printf("Get input node failed : node_idx: %d, tensor_idx: %d\n",node_idx,tensor_idx);
        return 1;
    }

    int dims[] = {1, 3, img_h, img_w};
    set_tensor_shape(input_tensor, dims, 4);
    prerun_graph(graph);

    int repeat_count = 1;
    const char *repeat = std::getenv("REPEAT_COUNT");

    if (repeat)
        repeat_count = std::strtoul(repeat, NULL, 10);

	//warm up
    get_input_data_ssd(image_file, input_data, img_h,  img_w);
    set_tensor_buffer(input_tensor, input_data, img_size * 4);
    run_graph(graph, 1);


    struct timeval t0, t1;
    float total_time = 0.f;
    for (int i = 0; i < repeat_count; i++)
    {
        get_input_data_ssd(image_file, input_data, img_h,  img_w);
  
        gettimeofday(&t0, NULL);
        set_tensor_buffer(input_tensor, input_data, img_size * 4);
        run_graph(graph, 1);

        gettimeofday(&t1, NULL);
        float mytime = (float)((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
        total_time += mytime;

    }
    std::cout << "--------------------------------------\n";
    std::cout << "repeat " << repeat_count << " times, avg time per run is " << total_time / repeat_count << " ms\n";
    tensor_t out_tensor = get_graph_output_tensor(graph, 0,0);//"detection_out");
    int out_dim[4];
    get_tensor_shape( out_tensor, out_dim, 4);
    float *outdata = (float *)get_tensor_buffer(out_tensor);
    int num=out_dim[1];
    float show_threshold=0.5;
    
    post_process_ssd(image_file,show_threshold, outdata, num,save_name);
	
	put_graph_tensor(out_tensor);
    put_graph_tensor(input_tensor);
    
    postrun_graph(graph);
    free(input_data);
    destroy_runtime_graph(graph);
    remove_model(model_name);

    return 0;
}
Ejemplo n.º 6
0
Archivo: netboot.c Proyecto: Prajna/xnu
static struct netboot_info *
netboot_info_init(struct in_addr iaddr)
{
    boolean_t			have_root_path = FALSE;
    struct netboot_info *	info = NULL;
    char * 			root_path = NULL;

    info = (struct netboot_info *)kalloc(sizeof(*info));
    bzero(info, sizeof(*info));
    info->client_ip = iaddr;
    info->image_type = kNetBootImageTypeUnknown;

    /* check for a booter-specified path then a NetBoot path */
    MALLOC_ZONE(root_path, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK);
    if (root_path  == NULL)
    	panic("netboot_info_init: M_NAMEI zone exhausted");
    if (PE_parse_boot_argn("rp0", root_path, MAXPATHLEN) == TRUE
	|| PE_parse_boot_argn("rp", root_path, MAXPATHLEN) == TRUE
	|| PE_parse_boot_argn("rootpath", root_path, MAXPATHLEN) == TRUE) {
	if (imageboot_format_is_valid(root_path)) {
	    printf("netboot_info_init: rp0='%s' isn't a network path,"
		   " ignoring\n", root_path);
	}
	else {
	    have_root_path = TRUE;
	}
    }
    if (have_root_path == FALSE) {
	have_root_path = get_root_path(root_path);
    }
    if (have_root_path) {
	const char * server_name = NULL;
	char * mount_point = NULL;
	char * image_path = NULL;
	struct in_addr 	server_ip;

	if (parse_image_path(root_path, &server_ip, &server_name, 
			     &mount_point, &image_path)) {
	    info->image_type = kNetBootImageTypeNFS;
	    info->server_ip = server_ip;
	    info->server_name_length = strlen(server_name) + 1;
	    info->server_name = (char *)kalloc(info->server_name_length);
	    info->mount_point_length = strlen(mount_point) + 1;
	    info->mount_point = (char *)kalloc(info->mount_point_length);
	    strlcpy(info->server_name, server_name, info->server_name_length);
	    strlcpy(info->mount_point, mount_point, info->mount_point_length);
	    
	    printf("netboot: NFS Server %s Mount %s", 
		   server_name, info->mount_point);
	    if (image_path != NULL) {
		boolean_t 	needs_slash = FALSE;
		
		info->image_path_length = strlen(image_path) + 1;
		if (image_path[0] != '/') {
		    needs_slash = TRUE;
		    info->image_path_length++;
		}
		info->image_path = (char *)kalloc(info->image_path_length);
		if (needs_slash) {
			info->image_path[0] = '/';
			strlcpy(info->image_path + 1, image_path,
					info->image_path_length - 1);
		} else {
			strlcpy(info->image_path, image_path,
					info->image_path_length);
		}
		printf(" Image %s", info->image_path);
	    }
	    printf("\n");
	}
	else if (strncmp(root_path, kNetBootRootPathPrefixHTTP, 
			 strlen(kNetBootRootPathPrefixHTTP)) == 0) {
	    info->image_type = kNetBootImageTypeHTTP;
	    save_path(&info->image_path, &info->image_path_length,
		      root_path);
	    printf("netboot: HTTP URL %s\n",  info->image_path);
	}	    
	else {
	    printf("netboot: root path uses unrecognized format\n");
	}

	/* check for image-within-image */
	if (info->image_path != NULL) {
		if (PE_parse_boot_argn(IMAGEBOOT_ROOT_ARG, root_path, MAXPATHLEN)
			|| PE_parse_boot_argn("rp1", root_path, MAXPATHLEN)) {
			/* rp1/root-dmg is the second-level image */
			save_path(&info->second_image_path, &info->second_image_path_length, 
					root_path);
		}
	}
	if (info->second_image_path != NULL) {
		printf("netboot: nested image %s\n", info->second_image_path);
	}
    }
    FREE_ZONE(root_path, MAXPATHLEN, M_NAMEI);
    return (info);
}
Ejemplo n.º 7
0
bool Application::is_correctly_installed()
{
    return !is_empty_string(get_root_path());
}