From 3e38be1fc6605ca41d40998608b56137c83291d9 Mon Sep 17 00:00:00 2001 From: Adarsh Yoga Date: Sun, 21 Apr 2024 04:17:45 +0000 Subject: [PATCH] test knn labels --- dpbench/benchmarks/default/knn/knn_initialize.py | 2 +- .../knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp | 2 +- .../knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dpbench/benchmarks/default/knn/knn_initialize.py b/dpbench/benchmarks/default/knn/knn_initialize.py index 2e76a31f..7af51027 100644 --- a/dpbench/benchmarks/default/knn/knn_initialize.py +++ b/dpbench/benchmarks/default/knn/knn_initialize.py @@ -24,7 +24,7 @@ def _gen_data_x(ip_size, data_dim, seed, dtype): def _gen_data_y(ip_size, classes_num, seed): default_rng.seed(seed) - data = default_rng.randint(classes_num, size=ip_size) + data = default_rng.randint(classes_num, size=ip_size, dtype=np.int64) return data def _gen_train_data(train_size, data_dim, classes_num, seed_train, dtype): diff --git a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp index e544dd83..b0240b6c 100644 --- a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp +++ b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp @@ -105,7 +105,7 @@ sycl::event knn_impl(sycl::queue q, size_t ith_idx = i * classes_num; size_t jth = queue_neighbors[j].label; - out << ith_idx << " " << jth << sycl::endl; + //out << ith_idx << " " << jth << sycl::endl; //d_votes_to_classes[ith_idx + jth] = jth; //d_votes_to_classes[(i*classes_num) + (queue_neighbors[j].label)] += 1; } diff --git a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp index 7976c4b8..fc41d7e8 100644 --- a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp +++ b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp @@ -39,6 +39,19 @@ void knn_sync(dpctl::tensor::usm_ndarray x_train, votes_to_classes)) throw std::runtime_error("Input arrays are not acceptable."); + size_t* train_labels = y_train.get_data(); + std::cout << "Labels size = " << y_train.get_size() << std::endl; + sycl::queue q = x_train.get_queue(); + + size_t h_labels[1024]; + + q.memcpy(h_labels,train_labels,sizeof(size_t)*1024); + q.wait(); + + for (int idx = 0; idx<1024;idx++) { + std::cout << "Train labels: "<< h_labels[idx] << std::endl; + } + auto typenum = x_train.get_typenum(); if (typenum == UAR_FLOAT) { sycl::event res_ev = knn_impl(