Skip to content

Commit a1d1565

Browse files
committed
add some comments
1 parent 7e0b51f commit a1d1565

File tree

6 files changed

+61
-28
lines changed

6 files changed

+61
-28
lines changed

paddle/math/TensorAssign.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
/**
2-
* TensorAssign.h
3-
*
4-
* Author: hedaoyuan (hedaoyuan@baidu.com)
5-
* Created on: 2016-10-08
6-
*
7-
* Copyright (c) Baidu.com, Inc. All Rights Reserved
8-
*
9-
*/
1+
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
1014

1115
#pragma once
1216

@@ -15,6 +19,10 @@
1519

1620
namespace paddle {
1721

22+
/**
23+
* \brief Tensor Assign Expression(return by lazyAssign,
24+
* and evaluated by AssignEvaluate)
25+
*/
1826
template<typename LhsType, typename RhsType, class T>
1927
class TensorAssignOp {
2028
public:
@@ -91,7 +99,11 @@ void AssignGpuEvaluate2(const int height, const int width,
9199
}
92100
#endif
93101

94-
// At least one assignment expression is required
102+
/**
103+
* \brief Evaluate one or more TensorAssignOp objects.
104+
*
105+
* \note At least one assignment expression is required
106+
*/
95107
template <typename Assign, typename... AssignOp>
96108
void AssignEvaluate(Assign&& assign, AssignOp&& ... args) {
97109
const bool useGpu_ = assign.useGpu();

paddle/math/TensorExpression.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,19 @@ class TensorExpression {
318318
return condition(constant(p1), constant(p2));
319319
}
320320

321+
/**
322+
* return a TensorConstant. A TensorConstant object hold a constant value.
323+
*/
321324
const TensorConstant<hppl::unary::constant<T>, const Derived, T>
322325
constant(T p) const {
323326
return TensorConstant<hppl::unary::constant<T>, const Derived, T>
324327
(hppl::unary::constant<T>(p), derived());
325328
}
326329

330+
/**
331+
* return a TensorAssignOp, and use AssignEvaluate to evaluate one or more
332+
* TensorAssignOp objects.
333+
*/
327334
template<typename ExpressionType>
328335
TensorAssignOp<Derived, ExpressionType, T>
329336
lazyAssign(const ExpressionType& expr) const {

paddle/math/tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ add_simple_unittest(test_perturbation)
1515
add_simple_unittest(test_CpuGpuVector)
1616
add_simple_unittest(test_Allocator)
1717
if(WITH_GPU)
18-
CUDA_ADD_EXECUTABLE(test_Tensor test_Tensor.cu)
19-
link_paddle_test(test_Tensor)
2018
if(COMPILER_SUPPORT_CXX11)
19+
CUDA_ADD_EXECUTABLE(test_Tensor test_Tensor.cu)
20+
link_paddle_test(test_Tensor)
2121
CUDA_ADD_EXECUTABLE(test_lazyAssign test_lazyAssign.cu)
2222
link_paddle_test(test_lazyAssign)
2323
endif()

paddle/math/tests/TensorCheck.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
/**
2-
* test_Tensor.cpp
3-
*
4-
* Author: hedaoyuan (hedaoyuan@baidu.com)
5-
* Created on: 2016-06-06
6-
*
7-
* Copyright (c) Baidu.com, Inc. All Rights Reserved
8-
*/
1+
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
914

1015
#include <gtest/gtest.h>
1116
#include "paddle/math/Matrix.h"

paddle/math/tests/test_TrainingAlgorithm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ int VectorCheckErr(const VectorPtr& vector1, const VectorPtr& vector2) {
9191
typedef std::function<void(size_t size, bool useGpu)> testMatrixFunc;
9292

9393
void testCase(testMatrixFunc matrixFunc) {
94+
#ifndef PADDLE_ONLY_CPU
9495
for (auto useGpu : {false, true}) {
96+
#else
97+
for (auto useGpu : {false}) {
98+
#endif
9599
for (auto size : {1, 32, 64, 128, 512, 1024, 4096, 32768, 65536, 131072,
96100
262144, 524288, 1048576, 2097152}) {
97101
LOG(INFO) << " size=" << size << " useGpu=" << useGpu;

paddle/math/tests/test_lazyAssign.cu

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
/**
2-
* test_lazyAssign.cpp
3-
*
4-
* Author: hedaoyuan (hedaoyuan@baidu.com)
5-
* Created on: 2016-10-15
6-
*
7-
* Copyright (c) Baidu.com, Inc. All Rights Reserved
8-
*/
1+
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserve.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
914

1015
#include <gtest/gtest.h>
1116
#include "paddle/math/Matrix.h"

0 commit comments

Comments
 (0)