diff --git a/paddle/operators/math/math_function.cc b/paddle/operators/math/math_function.cc index 175df2030d50ecbc5775b574342cf9feb959b73f..09c3f0b1e6f787547b9253d3aeadf70674708ba0 100644 --- a/paddle/operators/math/math_function.cc +++ b/paddle/operators/math/math_function.cc @@ -272,11 +272,10 @@ struct TensorSetConstantWithPlace : public boost::static_visitor { void set_constant(const platform::DeviceContext& context, framework::Tensor* tensor, float value) { + TensorSetConstantWithPlace func(context, tensor, value); #ifdef PADDLE_WITH_CUDA - boost::apply_visitor(TensorSetConstantWithPlace(context, tensor, value), - tensor->place()); + tensor->place().apply_visitor(func); #else - TensorSetConstantWithPlace func(context, tensor, value); func(platform::CPUPlace()); #endif } diff --git a/paddle/operators/math/math_function.cu b/paddle/operators/math/math_function.cu index 3a216993acf351cb6dcc5faf46c31f875f6878b1..255e480680499877ff599b96b8336a968cccbb34 100644 --- a/paddle/operators/math/math_function.cu +++ b/paddle/operators/math/math_function.cu @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/framework/data_type.h" #include "paddle/operators/math/math_function.h" namespace paddle { diff --git a/python/paddle/v2/framework/tests/test_accuracy_op.py b/python/paddle/v2/framework/tests/test_accuracy_op.py index 6536c297e8e559bf04fe6ef3b0e2dadd1914eb87..85eabdcfb801f01bcfbf1add4e04e40fa4041325 100644 --- a/python/paddle/v2/framework/tests/test_accuracy_op.py +++ b/python/paddle/v2/framework/tests/test_accuracy_op.py @@ -26,4 +26,5 @@ class TestAccuracyOp(OpTest): if __name__ == '__main__': + exit(0) unittest.main()