Test.cpp 3.38 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
/* 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: LI Yinqiao (li.yin.qiao.2012@hotmail.com) 2018-05-01
*/

#include "Test.h"

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

/* test for all Function */
bool Test()
{
    bool wrong = false;
    XPRINT(0, stdout, "Testing the XTensor utilites ... \n\n");
31
    
32
    wrong = !TestAbsolute() || wrong;
33
    wrong = !TestClip() || wrong;
34
    wrong = !TestCompare() || wrong;
xiaotong committed
35 36
    wrong = !TestConcatenate() || wrong;
    wrong = !TestConcatenateSolely() || wrong;
37
    wrong = !TestCos() || wrong;
38
    //wrong = !TestConvertDataType() || wrong;
39
    wrong = !TestCopyIndexed() || wrong;
40
    wrong = !TestCopyValues() || wrong;
41
    wrong = !TestDiv() || wrong;
42
    wrong = !TestDivDim() || wrong;
43
    wrong = !TestExp() || wrong;
44
    wrong = !TestGather() || wrong;
45
    wrong = !TestLog() || wrong;
xiaotong committed
46 47
    wrong = !TestMatrixMul() || wrong;
    wrong = !TestMatrixMul2D() || wrong;
liyinqiao committed
48
    wrong = !TestMatrixMul2DParallel() || wrong;
49
    wrong = !TestMatrixMulBatched() || wrong;
xiaotong committed
50
    wrong = !TestMerge() || wrong;
51
    wrong = !TestMultiply() || wrong;
52
    wrong = !TestMultiplyDim() || wrong;
xiaotong committed
53 54
    wrong = !TestNegate() || wrong;
    wrong = !TestNormalize() || wrong;
55
    wrong = !TestPower() || wrong;
xiaotong committed
56 57 58
    wrong = !TestReduceMax() || wrong;
    wrong = !TestReduceMean() || wrong;
    wrong = !TestReduceSum() || wrong;
59
    wrong = !TestReduceSumAll() || wrong;
60 61
    wrong = !TestReduceSumSquared() || wrong;
    wrong = !TestReduceVariance() || wrong;
62
    wrong = !TestRound() || wrong;
63 64
    wrong = !TestScaleAndShift() || wrong;
    wrong = !TestSelect() || wrong;
liyinqiao committed
65 66
    wrong = !TestSetAscendingOrder() || wrong;
    wrong = !TestSetData() || wrong;
67
    wrong = !TestSign() || wrong;
68
    wrong = !TestSin() || wrong;
xiaotong committed
69 70
    wrong = !TestSort() || wrong;
    wrong = !TestSplit() || wrong;
liyinqiao committed
71
    wrong = !TestSpread() || wrong;
72
    wrong = !TestSub() || wrong;
xiaotong committed
73
    wrong = !TestSum() || wrong;
74 75 76
    wrong = !TestSumDim() || wrong;
    wrong = !TestTan() || wrong;
    wrong = !TestTranspose() || wrong;
77
    wrong = !TestTopK() || wrong;
78
    wrong = !TestUnsqueeze() || wrong;
xiaotong committed
79
    wrong = !TestXMem() || wrong;
80 81
    
    wrong = !TestCrossEntropy() || wrong;
liyinqiao committed
82
    wrong = !TestDropout() || wrong;
83 84 85 86 87 88 89
    wrong = !TestHardTanH() || wrong;
    wrong = !TestIdentity() || wrong;
    wrong = !TestLogSoftmax() || wrong;
    wrong = !TestLoss() || wrong;
    wrong = !TestRectify() || wrong;
    wrong = !TestSigmoid() || wrong;
    wrong = !TestSoftmax() || wrong;
xiaotong committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106

    /* other test */
    /*
    TODO!!
    */

    if (wrong) {
        XPRINT(0, stdout, "Something goes wrong! Please check the code!\n");
        return false;
    }
    else {
        XPRINT(0, stdout, "OK! Everything is good!\n");
        return true;
    }
}

} // namespace nts(NiuTrans.Tensor)