未验证 提交 0c5cbc4e 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #7817 from reyoung/feature/rename_is_compile_gpu_to_is_compiled_with_cuda

Rename is_compile_gpu to is_compiled_with_cuda
...@@ -53,7 +53,7 @@ static size_t UniqueIntegerGenerator(const std::string &prefix) { ...@@ -53,7 +53,7 @@ static size_t UniqueIntegerGenerator(const std::string &prefix) {
return generators[prefix].fetch_add(1); return generators[prefix].fetch_add(1);
} }
bool IsCompileGPU() { bool IsCompiledWithCUDA() {
#ifndef PADDLE_WITH_CUDA #ifndef PADDLE_WITH_CUDA
return false; return false;
#else #else
...@@ -431,7 +431,7 @@ All parameter, weight, gradient are variables in Paddle. ...@@ -431,7 +431,7 @@ All parameter, weight, gradient are variables in Paddle.
m.def("init_glog", framework::InitGLOG); m.def("init_glog", framework::InitGLOG);
m.def("init_devices", &framework::InitDevices); m.def("init_devices", &framework::InitDevices);
m.def("is_compile_gpu", IsCompileGPU); m.def("is_compiled_with_cuda", IsCompiledWithCUDA);
m.def("set_feed_variable", framework::SetFeedVariable); m.def("set_feed_variable", framework::SetFeedVariable);
m.def("get_fetch_variable", framework::GetFetchVariable); m.def("get_fetch_variable", framework::GetFetchVariable);
......
...@@ -89,7 +89,7 @@ def __bootstrap__(): ...@@ -89,7 +89,7 @@ def __bootstrap__():
read_env_flags = [ read_env_flags = [
'use_pinned_memory', 'check_nan_inf', 'do_memory_benchmark' 'use_pinned_memory', 'check_nan_inf', 'do_memory_benchmark'
] ]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
read_env_flags += ['fraction_of_gpu_memory_to_use', 'op_sync'] read_env_flags += ['fraction_of_gpu_memory_to_use', 'op_sync']
core.init_gflags([sys.argv[0]] + core.init_gflags([sys.argv[0]] +
["--tryfromenv=" + ",".join(read_env_flags)]) ["--tryfromenv=" + ",".join(read_env_flags)])
......
...@@ -334,7 +334,7 @@ class OpTest(unittest.TestCase): ...@@ -334,7 +334,7 @@ class OpTest(unittest.TestCase):
def check_output(self, atol=1e-5): def check_output(self, atol=1e-5):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu() and core.op_support_gpu(self.op_type): if core.is_compiled_with_cuda() and core.op_support_gpu(self.op_type):
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.check_output_with_place(place, atol) self.check_output_with_place(place, atol)
...@@ -367,7 +367,7 @@ class OpTest(unittest.TestCase): ...@@ -367,7 +367,7 @@ class OpTest(unittest.TestCase):
max_relative_error=0.005, max_relative_error=0.005,
user_defined_grads=None): user_defined_grads=None):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu() and core.op_support_gpu(self.op_type): if core.is_compiled_with_cuda() and core.op_support_gpu(self.op_type):
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.check_grad_with_place(place, inputs_to_check, output_names, self.check_grad_with_place(place, inputs_to_check, output_names,
......
...@@ -180,7 +180,7 @@ class TestSparseAdagradOp(unittest.TestCase): ...@@ -180,7 +180,7 @@ class TestSparseAdagradOp(unittest.TestCase):
def test_sparse_adagrad(self): def test_sparse_adagrad(self):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.check_with_place(place) self.check_with_place(place)
......
...@@ -305,7 +305,7 @@ class TestSparseAdamOp(unittest.TestCase): ...@@ -305,7 +305,7 @@ class TestSparseAdamOp(unittest.TestCase):
def test_sparse_sgd(self): def test_sparse_sgd(self):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.check_with_place(place) self.check_with_place(place)
......
...@@ -352,7 +352,7 @@ class TestBatchNormOp(OpTest): ...@@ -352,7 +352,7 @@ class TestBatchNormOp(OpTest):
print "op test backward passed: ", str(place), data_layout print "op test backward passed: ", str(place), data_layout
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu() and core.op_support_gpu("batch_norm"): if core.is_compiled_with_cuda() and core.op_support_gpu("batch_norm"):
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
......
...@@ -33,7 +33,7 @@ class TestGaussianRandomOp(unittest.TestCase): ...@@ -33,7 +33,7 @@ class TestGaussianRandomOp(unittest.TestCase):
self.gaussian_random_test(place=fluid.CPUPlace()) self.gaussian_random_test(place=fluid.CPUPlace())
def test_gpu(self): def test_gpu(self):
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
self.gaussian_random_test(place=fluid.CUDAPlace(0)) self.gaussian_random_test(place=fluid.CUDAPlace(0))
def gaussian_random_test(self, place): def gaussian_random_test(self, place):
......
...@@ -46,7 +46,7 @@ class TestNormalization(unittest.TestCase): ...@@ -46,7 +46,7 @@ class TestNormalization(unittest.TestCase):
"""Run the test program. """Run the test program.
""" """
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
......
...@@ -18,7 +18,8 @@ import paddle.v2.fluid.core as core ...@@ -18,7 +18,8 @@ import paddle.v2.fluid.core as core
class TestOpSupportGPU(unittest.TestCase): class TestOpSupportGPU(unittest.TestCase):
def test_case(self): def test_case(self):
self.assertEqual(core.is_compile_gpu(), core.op_support_gpu("sum")) self.assertEqual(core.is_compiled_with_cuda(),
core.op_support_gpu("sum"))
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -53,7 +53,7 @@ class BaseParallelForTest(unittest.TestCase): ...@@ -53,7 +53,7 @@ class BaseParallelForTest(unittest.TestCase):
fetch=fetch, fetch=fetch,
place=cpu, place=cpu,
use_parallel=True) use_parallel=True)
if fluid.core.is_compile_gpu(): if fluid.core.is_compiled_with_cuda():
gpu = fluid.CUDAPlace(0) gpu = fluid.CUDAPlace(0)
result_gpu = self._run_test_impl_( result_gpu = self._run_test_impl_(
callback=callback, callback=callback,
......
...@@ -23,7 +23,7 @@ import paddle.v2.fluid.core as core ...@@ -23,7 +23,7 @@ import paddle.v2.fluid.core as core
class TestProfiler(unittest.TestCase): class TestProfiler(unittest.TestCase):
def test_nvprof(self): def test_nvprof(self):
if not fluid.core.is_compile_gpu(): if not fluid.core.is_compiled_with_cuda():
return return
epoc = 8 epoc = 8
dshape = [4, 3, 28, 28] dshape = [4, 3, 28, 28]
...@@ -42,7 +42,7 @@ class TestProfiler(unittest.TestCase): ...@@ -42,7 +42,7 @@ class TestProfiler(unittest.TestCase):
os.remove(output_file) os.remove(output_file)
def net_profiler(self, state): def net_profiler(self, state):
if state == 'GPU' and not core.is_compile_gpu(): if state == 'GPU' and not core.is_compiled_with_cuda():
return return
startup_program = fluid.Program() startup_program = fluid.Program()
main_program = fluid.Program() main_program = fluid.Program()
......
...@@ -45,7 +45,7 @@ class TestReorderLoDTensor(unittest.TestCase): ...@@ -45,7 +45,7 @@ class TestReorderLoDTensor(unittest.TestCase):
outputs = [] outputs = []
input_grads = [] input_grads = []
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.set_inputs(place) self.set_inputs(place)
......
...@@ -91,7 +91,7 @@ class TestSparseSGDOp(unittest.TestCase): ...@@ -91,7 +91,7 @@ class TestSparseSGDOp(unittest.TestCase):
def test_sparse_sgd(self): def test_sparse_sgd(self):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
for place in places: for place in places:
self.check_with_place(place) self.check_with_place(place)
......
...@@ -21,7 +21,7 @@ from paddle.v2.fluid.op import Operator ...@@ -21,7 +21,7 @@ from paddle.v2.fluid.op import Operator
class TestSpliteSelectedRows(unittest.TestCase): class TestSpliteSelectedRows(unittest.TestCase):
def get_places(self): def get_places(self):
places = [core.CPUPlace()] places = [core.CPUPlace()]
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
places.append(core.CUDAPlace(0)) places.append(core.CUDAPlace(0))
return places return places
......
...@@ -36,7 +36,7 @@ class TestUniformRandomOp(unittest.TestCase): ...@@ -36,7 +36,7 @@ class TestUniformRandomOp(unittest.TestCase):
self.uniform_random_test(place=core.CPUPlace()) self.uniform_random_test(place=core.CPUPlace())
def test_gpu(self): def test_gpu(self):
if core.is_compile_gpu(): if core.is_compiled_with_cuda():
self.uniform_random_test(place=core.CUDAPlace(0)) self.uniform_random_test(place=core.CUDAPlace(0))
def uniform_random_test(self, place): def uniform_random_test(self, place):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册