提交 fe04175e 编写于 作者: Y Yi Wang

Fix comparison between signed and unsigned values

上级 338d861f
...@@ -157,22 +157,22 @@ class CPUKernalMultiInputsTest : public OpKernel { ...@@ -157,22 +157,22 @@ class CPUKernalMultiInputsTest : public OpKernel {
ASSERT_EQ(xs[2], "x2"); ASSERT_EQ(xs[2], "x2");
auto inVar0 = ctx.MultiInputVar("xs"); auto inVar0 = ctx.MultiInputVar("xs");
ASSERT_EQ(inVar0.size(), 3); ASSERT_EQ(inVar0.size(), 3U);
auto intVar1 = ctx.InputVar("k"); auto intVar1 = ctx.InputVar("k");
ASSERT_NE(intVar1, nullptr); ASSERT_NE(intVar1, nullptr);
auto outVar0 = ctx.MultiOutputVar("ys"); auto outVar0 = ctx.MultiOutputVar("ys");
ASSERT_EQ(outVar0.size(), 2); ASSERT_EQ(outVar0.size(), 2U);
auto inTensor0 = ctx.MultiInput<Tensor>("xs"); auto inTensor0 = ctx.MultiInput<Tensor>("xs");
ASSERT_EQ(inTensor0.size(), 3); ASSERT_EQ(inTensor0.size(), 3U);
auto intTensor1 = ctx.Input<Tensor>("k"); auto intTensor1 = ctx.Input<Tensor>("k");
ASSERT_NE(intTensor1, nullptr); ASSERT_NE(intTensor1, nullptr);
auto outTensor0 = ctx.MultiOutput<Tensor>("ys"); auto outTensor0 = ctx.MultiOutput<Tensor>("ys");
ASSERT_EQ(outTensor0.size(), 2); ASSERT_EQ(outTensor0.size(), 2U);
auto k = ctx.op_.Input("k"); auto k = ctx.op_.Input("k");
ASSERT_EQ(k, "k0"); ASSERT_EQ(k, "k0");
......
...@@ -32,7 +32,7 @@ TEST(BufferTest, SequenceIdArg) { ...@@ -32,7 +32,7 @@ TEST(BufferTest, SequenceIdArg) {
sizeOfValuType(VALUE_TYPE_INT32)); sizeOfValuType(VALUE_TYPE_INT32));
SequenceIdArg buffer(memory.getBuf(), shape); SequenceIdArg buffer(memory.getBuf(), shape);
EXPECT_EQ(buffer.data(), memory.getBuf()); EXPECT_EQ(buffer.data(), memory.getBuf());
EXPECT_EQ(buffer.numSeqs(), 9); EXPECT_EQ(buffer.numSeqs(), 9U);
} }
} // namespace paddle } // namespace paddle
...@@ -24,14 +24,14 @@ void FunctionApi(typename Tensor<real, DType>::Matrix& output, ...@@ -24,14 +24,14 @@ void FunctionApi(typename Tensor<real, DType>::Matrix& output,
template <> template <>
void FunctionApi<DEVICE_TYPE_CPU>(CpuMatrix& output, const CpuMatrix& input) { void FunctionApi<DEVICE_TYPE_CPU>(CpuMatrix& output, const CpuMatrix& input) {
EXPECT_EQ(output.getHeight(), 100); EXPECT_EQ(output.getHeight(), 100U);
EXPECT_EQ(output.getWidth(), 200); EXPECT_EQ(output.getWidth(), 200U);
} }
template <> template <>
void FunctionApi<DEVICE_TYPE_GPU>(GpuMatrix& output, const GpuMatrix& input) { void FunctionApi<DEVICE_TYPE_GPU>(GpuMatrix& output, const GpuMatrix& input) {
EXPECT_EQ(output.getHeight(), 10); EXPECT_EQ(output.getHeight(), 10U);
EXPECT_EQ(output.getWidth(), 20); EXPECT_EQ(output.getWidth(), 20U);
} }
template <DeviceType DType> template <DeviceType DType>
...@@ -85,14 +85,14 @@ void testBufferArgs(const BufferArgs& inputs, ...@@ -85,14 +85,14 @@ void testBufferArgs(const BufferArgs& inputs,
} }
void testBufferArgs(const BufferArgs& inputs, const CheckBufferArg& check) { void testBufferArgs(const BufferArgs& inputs, const CheckBufferArg& check) {
EXPECT_EQ(inputs.size(), 1); EXPECT_EQ(inputs.size(), 1U);
check(inputs[0]); check(inputs[0]);
} }
TEST(Arguments, Matrix) { TEST(Arguments, Matrix) {
MatrixPtr matrix = Matrix::create(100, 200); MatrixPtr matrix = Matrix::create(100, 200);
CheckBufferArg check = [=](const BufferArg& arg) { CheckBufferArg check = [=](const BufferArg& arg) {
EXPECT_EQ(arg.shape().ndims(), 2); EXPECT_EQ(arg.shape().ndims(), 2U);
EXPECT_EQ(arg.shape()[0], 100); EXPECT_EQ(arg.shape()[0], 100);
EXPECT_EQ(arg.shape()[1], 200); EXPECT_EQ(arg.shape()[1], 200);
EXPECT_EQ(arg.data(), matrix->getData()); EXPECT_EQ(arg.data(), matrix->getData());
......
...@@ -19,35 +19,35 @@ namespace paddle { ...@@ -19,35 +19,35 @@ namespace paddle {
TEST(TensorShape, Constructor) { TEST(TensorShape, Constructor) {
TensorShape t1; TensorShape t1;
EXPECT_EQ(t1.ndims(), 0); EXPECT_EQ(t1.ndims(), 0U);
EXPECT_EQ(t1.getElements(), 0); EXPECT_EQ(t1.getElements(), 0U);
TensorShape t2(3); TensorShape t2(3);
EXPECT_EQ(t2.ndims(), 3); EXPECT_EQ(t2.ndims(), 3U);
EXPECT_EQ(t2.getElements(), 1); EXPECT_EQ(t2.getElements(), 1U);
TensorShape t3({8, 10}); TensorShape t3({8, 10});
EXPECT_EQ(t3.ndims(), 2); EXPECT_EQ(t3.ndims(), 2U);
EXPECT_EQ(t3.getElements(), 80); EXPECT_EQ(t3.getElements(), 80U);
TensorShape t4(t3); TensorShape t4(t3);
EXPECT_EQ(t4.ndims(), t3.ndims()); EXPECT_EQ(t4.ndims(), t3.ndims());
EXPECT_EQ(t4.getElements(), t3.getElements()); EXPECT_EQ(t4.getElements(), t3.getElements());
TensorShape t5({1, 2, 3, 4, 5}); TensorShape t5({1, 2, 3, 4, 5});
EXPECT_EQ(t5.ndims(), 5); EXPECT_EQ(t5.ndims(), 5U);
EXPECT_EQ(t5.getElements(), 120); EXPECT_EQ(t5.getElements(), 120U);
} }
TEST(TensorShape, GetAndSet) { TEST(TensorShape, GetAndSet) {
TensorShape t({1, 2, 3}); TensorShape t({1, 2, 3});
EXPECT_EQ(t.ndims(), 3); EXPECT_EQ(t.ndims(), 3U);
EXPECT_EQ(t.getElements(), 6); EXPECT_EQ(t.getElements(), 6U);
EXPECT_EQ(t[1], 2); EXPECT_EQ(t[1], 2);
t.setDim(1, 100); t.setDim(1, 100);
EXPECT_EQ(t.getElements(), 300); EXPECT_EQ(t.getElements(), 300U);
EXPECT_EQ(t[1], 100); EXPECT_EQ(t[1], 100U);
} }
} // namespace paddle } // namespace paddle
...@@ -19,9 +19,9 @@ namespace paddle { ...@@ -19,9 +19,9 @@ namespace paddle {
TEST(TensorType, Matrix) { TEST(TensorType, Matrix) {
Tensor<real, DEVICE_TYPE_CPU>::Matrix matrix(100, 200); Tensor<real, DEVICE_TYPE_CPU>::Matrix matrix(100, 200);
EXPECT_EQ(matrix.getHeight(), 100); EXPECT_EQ(matrix.getHeight(), 100U);
EXPECT_EQ(matrix.getWidth(), 200); EXPECT_EQ(matrix.getWidth(), 200U);
EXPECT_EQ(matrix.getElementCnt(), 100 * 200); EXPECT_EQ(matrix.getElementCnt(), 100U * 200U);
EXPECT_EQ(matrix.useGpu(), false); EXPECT_EQ(matrix.useGpu(), false);
Tensor<real, DEVICE_TYPE_GPU>::Matrix testGpu(100, 200); Tensor<real, DEVICE_TYPE_GPU>::Matrix testGpu(100, 200);
...@@ -33,15 +33,15 @@ TEST(TensorType, Vector) { ...@@ -33,15 +33,15 @@ TEST(TensorType, Vector) {
Tensor<real, DEVICE_TYPE_GPU>::Vector gpuVector(100); Tensor<real, DEVICE_TYPE_GPU>::Vector gpuVector(100);
EXPECT_EQ(cpuVector.useGpu(), false); EXPECT_EQ(cpuVector.useGpu(), false);
EXPECT_EQ(gpuVector.useGpu(), true); EXPECT_EQ(gpuVector.useGpu(), true);
EXPECT_EQ(cpuVector.getSize(), 100); EXPECT_EQ(cpuVector.getSize(), 100U);
EXPECT_EQ(gpuVector.getSize(), 100); EXPECT_EQ(gpuVector.getSize(), 100U);
Tensor<int, DEVICE_TYPE_CPU>::Vector cpuIVector(100); Tensor<int, DEVICE_TYPE_CPU>::Vector cpuIVector(100);
Tensor<int, DEVICE_TYPE_GPU>::Vector gpuIVector(100); Tensor<int, DEVICE_TYPE_GPU>::Vector gpuIVector(100);
EXPECT_EQ(cpuIVector.useGpu(), false); EXPECT_EQ(cpuIVector.useGpu(), false);
EXPECT_EQ(gpuIVector.useGpu(), true); EXPECT_EQ(gpuIVector.useGpu(), true);
EXPECT_EQ(cpuIVector.getSize(), 100); EXPECT_EQ(cpuIVector.getSize(), 100U);
EXPECT_EQ(gpuIVector.getSize(), 100); EXPECT_EQ(gpuIVector.getSize(), 100U);
} }
TEST(TensorType, EmptyMatrix) { TEST(TensorType, EmptyMatrix) {
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
vals.push_back(s.str()); vals.push_back(s.str());
} }
size_t pos = 0; size_t pos = 0;
int i = 0; size_t i = 0;
std::ostringstream s; std::ostringstream s;
const std::string& format = config_.user_arg(); const std::string& format = config_.user_arg();
while (true) { while (true) {
......
...@@ -1146,7 +1146,7 @@ void testBatch2seqPadding(int batchSize, int inputDim) { ...@@ -1146,7 +1146,7 @@ void testBatch2seqPadding(int batchSize, int inputDim) {
IVectorPtr cpuSequence; IVectorPtr cpuSequence;
generateSequenceStartPositions(batchSize, cpuSequence); generateSequenceStartPositions(batchSize, cpuSequence);
for (int i = 0; i < cpuSequence->getSize(); ++i) { for (int i = 0; i < int(cpuSequence->getSize()); ++i) {
(cpuSequence->getData())[i] += 1; // so no way that maxSeqLen is 0; (cpuSequence->getData())[i] += 1; // so no way that maxSeqLen is 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册