Skip to content

Commit 9b7cd7f

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into feature/tensor_support_uint8
2 parents fd2b4b4 + 4473eff commit 9b7cd7f

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

paddle/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ if(NOT WITH_FLUID_ONLY)
2424
endif()
2525

2626
add_subdirectory(testing)
27-
if(NOT MOBILE_INFERENCE AND NOT RPI)
27+
if(NOT MOBILE_INFERENCE AND NOT RPI AND NOT WITH_C_API)
2828
add_subdirectory(fluid)
2929
endif()

paddle/fluid/framework/operator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ limitations under the License. */
3333
#include "paddle/fluid/framework/tensor.h"
3434
#include "paddle/fluid/platform/device_context.h"
3535
#include "paddle/fluid/platform/variant.h"
36-
#include "paddle/utils/Error.h"
3736

3837
namespace paddle {
3938
namespace framework {

paddle/scripts/paddle_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ function main() {
504504
;;
505505
capi)
506506
cmake_gen ${PYTHON_ABI:-""}
507+
build
507508
gen_capi_package
508509
;;
509510
fluid_inference_lib)

python/paddle/fluid/tests/unittests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ list(REMOVE_ITEM TEST_OPS test_fetch_var)
6666
list(REMOVE_ITEM TEST_OPS test_parallel_op)
6767
list(REMOVE_ITEM TEST_OPS test_dynrnn_static_input)
6868
list(REMOVE_ITEM TEST_OPS test_dist_train)
69+
list(REMOVE_ITEM TEST_OPS test_network_with_dtype)
6970

7071
# tests that can be bundled together in one python process for speed.
7172
if(WITH_FAST_BUNDLE_TEST)
@@ -83,6 +84,7 @@ py_test_modules(test_parallel_executor MODULES test_parallel_executor)
8384
py_test_modules(test_warpctc_op MODULES test_warpctc_op ENVS FLAGS_warpctc_dir=${WARPCTC_LIB_DIR})
8485
py_test_modules(test_train_dyn_rnn MODULES test_dyn_rnn)
8586
py_test_modules(test_mul_op MODULES test_mul_op)
87+
py_test_modules(test_network_with_dtype MODULES test_network_with_dtype)
8688

8789
# tests that need to be run in separate process.
8890
py_test_modules(test_multihead_attention MODULES test_multihead_attention)

python/paddle/fluid/tests/unittests/test_network_with_dtype.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,43 @@
2424

2525

2626
class TestNetWithDtype(unittest.TestCase):
27-
def set_network(self):
27+
def setUp(self):
2828
self.dtype = "float64"
2929
self.init_dtype()
30-
main = fluid.Program()
31-
with fluid.program_guard(main):
32-
self.x = fluid.layers.data(name='x', shape=[13], dtype=self.dtype)
33-
self.y = fluid.layers.data(name='y', shape=[1], dtype=self.dtype)
34-
y_predict = fluid.layers.fc(input=self.x, size=1, act=None)
3530

36-
cost = fluid.layers.square_error_cost(input=y_predict, label=self.y)
31+
def run_net_on_place(self, place):
32+
main = fluid.Program()
33+
startup = fluid.Program()
34+
with fluid.program_guard(main, startup):
35+
x = fluid.layers.data(name='x', shape=[13], dtype=self.dtype)
36+
y = fluid.layers.data(name='y', shape=[1], dtype=self.dtype)
37+
y_predict = fluid.layers.fc(input=x, size=1, act=None)
38+
cost = fluid.layers.square_error_cost(input=y_predict, label=y)
3739
avg_cost = fluid.layers.mean(cost)
38-
self.program = main
39-
self.fetch_list = [avg_cost]
40+
sgd_optimizer = fluid.optimizer.SGD(learning_rate=0.001)
41+
sgd_optimizer.minimize(avg_cost)
4042

41-
sgd_optimizer = fluid.optimizer.SGD(learning_rate=0.001)
42-
sgd_optimizer.minimize(avg_cost)
43-
44-
def run_net_on_place(self, place):
43+
fetch_list = [avg_cost]
4544
train_reader = paddle.batch(
4645
paddle.dataset.uci_housing.train(), batch_size=BATCH_SIZE)
47-
feeder = fluid.DataFeeder(place=place, feed_list=[self.x, self.y])
46+
feeder = fluid.DataFeeder(place=place, feed_list=[x, y])
4847
exe = fluid.Executor(place)
49-
exe.run(fluid.default_startup_program())
48+
exe.run(startup)
5049
for data in train_reader():
51-
exe.run(self.program,
52-
feed=feeder.feed(data),
53-
fetch_list=self.fetch_list)
50+
exe.run(main, feed=feeder.feed(data), fetch_list=fetch_list)
5451
# the main program is runable, the datatype is fully supported
5552
break
5653

5754
def init_dtype(self):
5855
pass
5956

6057
def test_cpu(self):
61-
self.set_network()
6258
place = fluid.CPUPlace()
6359
self.run_net_on_place(place)
6460

6561
def test_gpu(self):
6662
if not core.is_compiled_with_cuda():
6763
return
68-
self.set_network()
6964
place = fluid.CUDAPlace(0)
7065
self.run_net_on_place(place)
7166

0 commit comments

Comments
 (0)