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

tests: add vulkan configuration in tests #1115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test-arange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -43,6 +47,16 @@ int main(int /*argc*/, const char** /*argv*/) {
}
#endif

#ifdef GGML_USE_VULKAN
if (!backend) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
backend = ggml_backend_vk_init(0);
if (!backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

const int num_tensors = 2;

struct ggml_init_params params = {
Expand Down
10 changes: 10 additions & 0 deletions tests/test-cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "ggml-cuda.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -36,6 +40,12 @@ ggml_backend_t make_backend(void) {
GGML_ASSERT(backend != NULL);
#endif

#ifdef GGML_USE_VULKAN
backend = ggml_backend_vk_init(0);
GGML_ASSERT(backend != NULL);
#endif


if (!backend) {
backend = ggml_backend_cpu_init();
}
Expand Down
14 changes: 14 additions & 0 deletions tests/test-conv-transpose-1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <cstdio>
#include <cstring>
#include <fstream>
Expand Down Expand Up @@ -122,6 +126,16 @@ void load_model(test_model & model, bool use_gpu = false) {
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
model.backend = ggml_backend_vk_init(0);
if (!model.backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

if(!model.backend) {
// fallback to CPU backend
model.backend = ggml_backend_cpu_init();
Expand Down
14 changes: 14 additions & 0 deletions tests/test-conv1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -96,6 +100,16 @@ void load_model(test_model & model, bool use_gpu = false) {
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
model.backend = ggml_backend_vk_init(0);
if (!model.backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

if(!model.backend) {
// fallback to CPU backend
model.backend = ggml_backend_cpu_init();
Expand Down
14 changes: 14 additions & 0 deletions tests/test-conv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -96,6 +100,16 @@ void load_model(test_model & model, bool use_gpu = false) {
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
model.backend = ggml_backend_vk_init(0);
if (!model.backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

if(!model.backend) {
// fallback to CPU backend
model.backend = ggml_backend_cpu_init();
Expand Down
14 changes: 14 additions & 0 deletions tests/test-mul-mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -67,6 +71,16 @@ void load_model(test_model & model, float* a, float* b, int M, int N, int K, boo
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
model.backend = ggml_backend_vk_init(0);
if (!model.backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

if(!model.backend) {
// fallback to CPU backend
model.backend = ggml_backend_cpu_init();
Expand Down
14 changes: 14 additions & 0 deletions tests/test-pad-reflect-1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -78,6 +82,16 @@ void test_pad_reflect_1d(bool use_gpu) {
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
backend = ggml_backend_vk_init(0);
if (!backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

if (!backend) {
fprintf(stderr, "%s: using CPU backend\n", __func__);
backend = ggml_backend_cpu_init();
Expand Down
14 changes: 14 additions & 0 deletions tests/test-timestep_embedding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "ggml-metal.h"
#endif

#ifdef GGML_USE_VULKAN
#include "ggml-vulkan.h"
#endif

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -117,6 +121,16 @@ int main(int argc, const char** argv) {
}
#endif

#ifdef GGML_USE_VULKAN
if (use_gpu) {
fprintf(stderr, "%s: using Vulkan backend\n", __func__);
backend = ggml_backend_vk_init(0);
if (!backend) {
fprintf(stderr, "%s: ggml_backend_vk_init() failed\n", __func__);
}
}
#endif

const int num_tensors = 2;

struct ggml_init_params params = {
Expand Down