Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to find a function wehn build unit-test #1413

Closed
lzhao4ever opened this issue Feb 22, 2017 · 4 comments
Closed

fail to find a function wehn build unit-test #1413

lzhao4ever opened this issue Feb 22, 2017 · 4 comments
Assignees

Comments

@lzhao4ever
Copy link
Contributor

lzhao4ever commented Feb 22, 2017

In #1337, I got error messages from Travis CI as follows. This error doesn't appear in my local build. Could you please help me?

[ 76%] Built target paddle_gserver

Scanning dependencies of target paddle_network

[ 76%] Building CXX object paddle/pserver/CMakeFiles/paddle_network.dir/LightNetwork.cpp.o

[ 77%] Building CXX object paddle/pserver/CMakeFiles/paddle_network.dir/SocketChannel.cpp.o

[ 77%] Building CXX object paddle/pserver/CMakeFiles/paddle_network.dir/ProtoServer.cpp.o

Linking CXX static library libpaddle_network.a

Done processing LightNetwork.cpp

Total errors found: 0

Done processing ProtoServer.cpp

Total errors found: 0

Done processing SocketChannel.cpp

Total errors found: 0

Done processing LightNetwork.h

Total errors found: 0

Done processing ProtoServer.h

Total errors found: 0

Done processing SocketChannel.h

Total errors found: 0

[ 77%] Built target paddle_network

Scanning dependencies of target paddle_pserver

[ 77%] Building CXX object paddle/pserver/CMakeFiles/paddle_pserver.dir/BaseClient.cpp.o

[ 78%] Building CXX object paddle/pserver/CMakeFiles/paddle_pserver.dir/ParameterClient2.cpp.o

[ 78%] Building CXX object paddle/pserver/CMakeFiles/paddle_pserver.dir/ParameterServer2.cpp.o

[ 78%] Building CXX object paddle/pserver/CMakeFiles/paddle_pserver.dir/SparseParameterDistribution.cpp.o

[ 79%] Building CXX object paddle/pserver/CMakeFiles/paddle_pserver.dir/ParameterServerController.cpp.o

Linking CXX static library libpaddle_pserver.a

Done processing BaseClient.cpp

Total errors found: 0

Done processing ParameterClient2.cpp

Total errors found: 0

Done processing ParameterServer2.cpp

Total errors found: 0

Done processing ParameterServerController.cpp

Total errors found: 0

Done processing SparseParameterDistribution.cpp

Total errors found: 0

Done processing BaseClient.h

Total errors found: 0

Done processing ParameterClient2.h

Total errors found: 0

Done processing ParameterServer2.h

Total errors found: 0

Done processing ParameterServerController.h

Total errors found: 0

Done processing SparseParameterDistribution.h

Total errors found: 0

[ 79%] Built target paddle_pserver

Scanning dependencies of target test_CustomStackTrace

[ 79%] Building CXX object paddle/utils/tests/CMakeFiles/test_CustomStackTrace.dir/test_CustomStackTrace.cpp.o

Linking CXX executable test_CustomStackTrace

Done processing test_CustomStackTrace.cpp

Total errors found: 0

../../math/libpaddle_math.a(Matrix.cpp.o): In function `paddle::GpuMatrix::classificationError(paddle::Matrix&, paddle::VectorT<int>&, unsigned long)':

/home/travis/build/PaddlePaddle/Paddle/paddle/math/Matrix.cpp:821: undefined reference to `hl_matrix_classification_error(float*, int, int*, float*, int, int, int, int, int*, float*)'

collect2: error: ld returned 1 exit status

make[2]: *** [paddle/utils/tests/test_CustomStackTrace] Error 1

make[1]: *** [paddle/utils/tests/CMakeFiles/test_CustomStackTrace.dir/all] Error 2

make: *** [all] Error 2
@gangliao
Copy link
Contributor

gangliao commented Feb 22, 2017

这个是因为你要考虑cpu stub啊。stub/hl_matrix_stub.h
添加:

inline int hl_matrix_classification_error(Elem_t* topVal, int ldv,
                                          int* topIds,
                                          Elem_t* src, int lds,
                                          int dim,
                                          int topkSize,
                                          int numSamples,
                                          int* label,
                                          Elem_t* recResult) {
  return HPPL_RET_OK;
}

@gangliao
Copy link
Contributor

可以考虑加一些单测:

test_matrixCompare.cpp

void testMatrixClassificationError(int samples, int dim, int beamSize) {
  MatrixPtr cpuOut = std::make_shared<CpuMatrix>(samples, 1);
  MatrixPtr gpuOut = std::make_shared<GpuMatrix>(samples, 1);
  MatrixPtr cpuSrc = std::make_shared<CpuMatrix>(samples, dim);
  MatrixPtr gpuSrc = std::make_shared<GpuMatrix>(samples, dim);
  IVectorPtr cpuLbl = std::make_shared<CpuIVector>(samples);
  IVectorPtr gpuLbl = std::make_shared<GpuIVector>(samples);

  cpuSrc->randomizeUniform();
  gpuSrc->copyFrom(*cpuSrc);

  int* labels = cpuLbl->getData();
  for (int i = 0; i < samples; ++i) {
    labels[i] = (int)rand() % dim;
    CHECK_LT(labels[i], dim);
  }
  gpuLbl->copyFrom(*cpuLbl);

  cpuOut->classificationError(cpuSrc, cpuLbl, beamSize);
  gpuOut->classificationError(gpuSrc, gpuLbl, beamSize);

  MatrixPtr gpuRes = std::make_shared<CpuMatrix>(samples, 1);
  gpuRes->copyFrom(*gpuOut);

  MatrixCheckEqual(*gpuRes, *cpuOut);
}

TEST(Matrix, classificationError) {
  for (auto samples : {1, 5, 31, 90, 150, 300}) {
    for (auto dim : {1, 5, 8, 10, 15, 64, 80, 120, 256, 300,
                    1280, 5120, 50000}) {
      for (auto beamSize : {1, 5, 10, 20, 40, (int)rand() % dim + 1}) {
        if (beamSize > dim ) continue;
        VLOG(3) << " sample= " << samples
                << " beamSize= " << beamSize
                << " dim= " << dim;
        testMatrixClassificationError(samples, dim, beamSize);
      }
    }
  }
}

@hedaoyuan
Copy link
Contributor

#892 (comment) 第三条。
修改hl_matrix_stub.h里面的hl_matrix_classification_error定义。

@lzhao4ever
Copy link
Contributor Author

Got it. Thanks.

lizexu123 pushed a commit to lizexu123/Paddle that referenced this issue Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants