|
| 1 | +//***************************************************************************** |
| 2 | +// Copyright (c) 2016-2020, 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 | +#include <iostream> |
| 27 | +#include <list> |
| 28 | + |
| 29 | +#include <dpnp_iface.hpp> |
| 30 | +#include "dpnp_fptr.hpp" |
| 31 | +#include "dpnp_utils.hpp" |
| 32 | +#include "queue_sycl.hpp" |
| 33 | + |
| 34 | + |
| 35 | +template <typename _DataType> |
| 36 | +class dpnp_take_c_kernel; |
| 37 | + |
| 38 | +template <typename _DataType> |
| 39 | +void dpnp_take_c(void* array1_in, void* indices1, void* result1, size_t size) |
| 40 | +{ |
| 41 | + _DataType* array_1 = reinterpret_cast<_DataType*>(array1_in); |
| 42 | + _DataType* result = reinterpret_cast<_DataType*>(result1); |
| 43 | + size_t* indices = reinterpret_cast<size_t*>(indices1); |
| 44 | + |
| 45 | + for (size_t i = 0; i < size; i++) |
| 46 | + { |
| 47 | + size_t ind = indices[i]; |
| 48 | + result[i] = array_1[ind]; |
| 49 | + } |
| 50 | + |
| 51 | + return; |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +void func_map_init_indexing_func(func_map_t& fmap) |
| 56 | +{ |
| 57 | + fmap[DPNPFuncName::DPNP_FN_TAKE][eft_INT][eft_INT] = {eft_INT, (void*)dpnp_take_c<int>}; |
| 58 | + fmap[DPNPFuncName::DPNP_FN_TAKE][eft_LNG][eft_LNG] = {eft_LNG, (void*)dpnp_take_c<long>}; |
| 59 | + fmap[DPNPFuncName::DPNP_FN_TAKE][eft_FLT][eft_FLT] = {eft_FLT, (void*)dpnp_take_c<float>}; |
| 60 | + fmap[DPNPFuncName::DPNP_FN_TAKE][eft_DBL][eft_DBL] = {eft_DBL, (void*)dpnp_take_c<double>}; |
| 61 | + |
| 62 | + return; |
| 63 | +} |
0 commit comments