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

memsize was hardcoded in preprocess_canny function #253

Open
chinshou opened this issue May 10, 2024 · 0 comments
Open

memsize was hardcoded in preprocess_canny function #253

chinshou opened this issue May 10, 2024 · 0 comments

Comments

@chinshou
Copy link

chinshou commented May 10, 2024

I tried to preprocess_canny a bitmap with a size of 1024x1024. Due to the hardcoding of the memsize,

uint8_t* preprocess_canny(uint8_t* img, int width, int height, float high_threshold, float low_threshold, float weak, float strong, bool inverse) {
struct ggml_init_params params;
params.mem_size = static_cast<size_t>(10 * 1024 * 1024); // 10
}
void convolve(struct ggml_tensor* input, struct ggml_tensor* output, struct ggml_tensor* kernel, int padding) {
struct ggml_init_params params;
params.mem_size = 20 * 1024 * 1024; // 10
}

the following code will raise an assert error:

struct ggml_tensor* image = ggml_new_tensor_4d(work_ctx, GGML_TYPE_F32, width, height, 3, 1);

I tried to increase the memsize to 4x the original hardcoded value, and it can now process the big image. However, I think we should dynamically calculate the memsize instead of hardcoding it.

Besides that , I think we should not free the image in the preprocess_canny because the memory may be alloced by 3rd language.

    free(img); <---- we should remove this call
    uint8_t* output = sd_tensor_to_image(image);
@chinshou chinshou changed the title memsize was hardcoding in preprocess_canny function memsize was hardcoded in preprocess_canny function May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant