DPNP C++ backend kernel library 0.18.0dev0
Data Parallel Extension for NumPy*
Loading...
Searching...
No Matches
validation_utils.hpp
1//*****************************************************************************
2// Copyright (c) 2024-2025, Intel Corporation
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are met:
7// - Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9// - Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23// THE POSSIBILITY OF SUCH DAMAGE.
24//*****************************************************************************
25
26#pragma once
27
28#include <string>
29#include <unordered_map>
30#include <vector>
31
32#include "dpctl4pybind11.hpp"
33
34namespace statistics::validation
35{
36using array_ptr = const dpctl::tensor::usm_ndarray *;
37using array_names = std::unordered_map<array_ptr, std::string>;
38
39std::string name_of(const array_ptr &arr, const array_names &names);
40
41void check_writable(const std::vector<array_ptr> &arrays,
42 const array_names &names);
43void check_c_contig(const std::vector<array_ptr> &arrays,
44 const array_names &names);
45void check_queue(const std::vector<array_ptr> &arrays,
46 const array_names &names,
47 const sycl::queue &exec_q);
48
49void check_no_overlap(const array_ptr &inputs,
50 const array_ptr &outputs,
51 const array_names &names);
52void check_no_overlap(const std::vector<array_ptr> &inputs,
53 const std::vector<array_ptr> &outputs,
54 const array_names &names);
55
56void check_num_dims(const array_ptr &arr,
57 const size_t ndim,
58 const array_names &names);
59void check_max_dims(const array_ptr &arr,
60 const size_t max_ndim,
61 const array_names &names);
62
63void check_size_at_least(const array_ptr &arr,
64 const size_t size,
65 const array_names &names);
66
67void common_checks(const std::vector<array_ptr> &inputs,
68 const std::vector<array_ptr> &outputs,
69 const array_names &names);
70} // namespace statistics::validation