Binary.cuh 2.14 KB
Newer Older
xiaotong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/* NiuTrans.Tensor - an open-source tensor library
* Copyright (C) 2017, Natural Language Processing Lab, Northestern University.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* $Created by: JIANG Yufan (email: jiangyufan2018@outlook.com) 2019-04-05
*/

#ifndef __BINARY_CUH__
#define __BINARY_CUH__

#include "../../XTensor.h"
#include "Binary.h"

namespace nts { // namespace nts(NiuTrans.Tensor)

#ifdef USE_CUDA

/* scale each entry (CUDA Kernel) */
__global__
xiaotong committed
34
void KernelScale(int * a, int * b, int size, int scale);
35 36
__global__
void KernelScale(int * a, int * b, int size, float scale);
xiaotong committed
37
/* scale each entry */
xiaotong committed
38
void _CudaScale(const XTensor * a, XTensor * b, int scale);
39
void _CudaScaleFloat(const XTensor * a, XTensor * b, float scale);
xiaotong committed
40 41 42

/* descale each entry (CUDA Kernel) */
__global__
xiaotong committed
43
void KernelDescale(int * a, int * b, int size, int scale);
44 45
__global__
void KernelDescale(int * a, int * b, int size, float scale);
xiaotong committed
46
/* descale each entry */
xiaotong committed
47
void _CudaDescale(const XTensor * a, XTensor * b, int scale);
48
void _CudaDescaleFloat(const XTensor * a, XTensor * b, float scale);
xiaotong committed
49 50 51

/* shift each entry (CUDA Kernel) */
__global__
xiaotong committed
52
void KernelShift(int * a, int * b, int size, int shift);
53 54
__global__
void KernelShift(int * a, int * b, int size, float shift);
xiaotong committed
55
/* shift each entry */
xiaotong committed
56
void _CudaShift(const XTensor * a, XTensor * b, int shift);
57
void _CudaShiftFloat(const XTensor * a, XTensor * b, float shift);
xiaotong committed
58 59 60

/* mod each entry (CUDA Kernel) */
__global__
xiaotong committed
61
void KernelMod(int * a, int * b, int size, int base);
xiaotong committed
62
/* mod each entry */
xiaotong committed
63
void _CudaMod(const XTensor * a, XTensor * b, int base);
xiaotong committed
64 65 66 67 68 69

#endif // USE_CUDA

} // namespace nts(NiuTrans.Tensor)

#endif // __BINARY_CUH__