diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index c318c5fc1ae20996d0ff8480da195a17703e04b7..676c1c7e2a1ea8e14802e39982ab9599c232a53a 100644 --- a/paddle/fluid/framework/executor.cc +++ b/paddle/fluid/framework/executor.cc @@ -12,6 +12,8 @@ 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 + #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/channel.h" @@ -384,6 +386,7 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope, CreateVariables(ctx->prog_, local_scope, ctx->block_id_); } + VLOG(3) << "Scope ptr " << local_scope; for (auto& op : ctx->ops_) { op->Run(*local_scope, place_); // CheckResult(op->Type(), ctx, local_scope); @@ -445,7 +448,11 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope, VLOG(3) << "after tensor copy"; float sum = .0; for(size_t i=0; i < check.numel(); ++i) { + if(std::type_index(check.type()) == std::type_index(typeid(int64_t))) { + sum += static_cast(check.data()[i]); + } else { sum += check.data()[i]; + } } VLOG(3) << "op " << op->Type() << " output var " << var_name << " sum " << sum; } diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 5b29f0cd4b0c75384a7d0c067728e0c919ec2dd2..3b4a620f8ce2ed6a4197063b54111a0e78d5c438 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -62,7 +62,7 @@ static DDim GetDims(const Scope& scope, const std::string& name, if (var->IsType()) { const LoDTensor& tensor = var->Get(); - if (UNLIKELY(!tensor.IsInitialized())) { + if (!tensor.IsInitialized()) { return DDim({-1}); } return tensor.dims(); @@ -91,13 +91,13 @@ static std::string GetDtype(const Scope& scope, const std::string& name) { if (var->IsType()) { const LoDTensor& tensor = var->Get(); - if (UNLIKELY(!tensor.IsInitialized())) { + if (!tensor.IsInitialized()) { return ""; } return DataTypeToString(ToDataType(tensor.type())); } else if (var->IsType()) { auto tensor = var->Get().value(); - if (UNLIKELY(!tensor.IsInitialized())) { + if (!tensor.IsInitialized()) { return "uninited"; } else { return DataTypeToString(ToDataType(tensor.type())); @@ -130,7 +130,7 @@ static LoD GetLoD(const Scope& scope, const std::string& name) { if (var->IsType()) { const LoDTensor& tensor = var->Get(); - if (UNLIKELY(!tensor.IsInitialized())) { + if (!tensor.IsInitialized()) { return default_lod; } return tensor.lod(); @@ -206,6 +206,7 @@ const std::vector& OperatorBase::Outputs( } std::string OperatorBase::DebugStringEx(const Scope* scope) const { + VLOG(3) << this->Type() << " scope ptr " << scope; std::stringstream ss; ss << "Op(" << type_ << "), inputs:{"; for (auto it = inputs_.begin(); it != inputs_.end();) { diff --git a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt index 93b554c83db105f83d7570d5e105f736cdabdbb0..c82837a490ef63f205ba5d327a16a91dcb4275a5 100644 --- a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt +++ b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt @@ -73,10 +73,11 @@ link_directories("${PADDLE_LIB}/paddle/fluid/inference") # add_executable(${DEMO_NAME} ${DEMO_NAME}.cc) # add_library(${DEMO_NAME} ${DEMO_NAME}.cc) - add_library(${DEMO_NAME} SHARED ${DEMO_NAME}.cc) add_executable(real_data_icnet_tester real_data_icnet_tester.cc) -add_executable(test test.cc) -add_executable(thread_icnet_test thread_icnet_test.cc) + +# add_library(${DEMO_NAME} SHARED ${DEMO_NAME}.cc) +# add_executable(test test.cc) +# add_executable(thread_icnet_test thread_icnet_test.cc) if(WITH_MKL) include_directories("${PADDLE_LIB}/third_party/install/mklml/include") @@ -94,11 +95,7 @@ endif() # Note: libpaddle_inference_api.so/a must put before libpaddle_fluid.so/a if(WITH_STATIC_LIB) set(DEPS -# ${PADDLE_LIB}/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX} - D:/Paddle/bazel-dll/fluid_install_dir/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX} - # E:/Paddle/build/paddle/fluid/inference/api/Release/libpaddle_inference_api${CMAKE_STATIC_LIBRARY_SUFFIX} - D:/Paddle/bazel-dll/paddle/fluid/inference/api/Release/libpaddle_inference_api${CMAKE_STATIC_LIBRARY_SUFFIX} - ) + ${PADDLE_LIB}/paddle/fluid/inference/libpaddle_fluid${CMAKE_STATIC_LIBRARY_SUFFIX}) else() set(DEPS ${PADDLE_LIB}/paddle/fluid/inference/libpaddle_fluid${CMAKE_SHARED_LIBRARY_SUFFIX}) @@ -129,10 +126,10 @@ if(WITH_GPU) endif() endif() -target_link_libraries(${DEMO_NAME} ${DEPS}) -target_link_libraries(test ${DEMO_NAME} ) -target_link_libraries(thread_icnet_test ${DEPS}) target_link_libraries(real_data_icnet_tester ${DEPS}) -target_compile_definitions(${DEMO_NAME} PRIVATE "API_DEFINITION") +# target_link_libraries(${DEMO_NAME} ${DEPS}) +# target_link_libraries(test ${DEMO_NAME} ) +# target_link_libraries(thread_icnet_test ${DEPS}) +# target_compile_definitions(${DEMO_NAME} PRIVATE "API_DEFINITION") diff --git a/paddle/fluid/inference/api/demo_ci/real_data_icnet_tester.cc b/paddle/fluid/inference/api/demo_ci/real_data_icnet_tester.cc index 677a6b976d4338498abd29f07bf043cdd3a3699a..4a27a375d96447972df3ea70340cd0a1cb79ff57 100644 --- a/paddle/fluid/inference/api/demo_ci/real_data_icnet_tester.cc +++ b/paddle/fluid/inference/api/demo_ci/real_data_icnet_tester.cc @@ -19,6 +19,7 @@ #include #include "paddle/fluid/inference/api/paddle_inference_api.h" + namespace paddle { // DEFINE_string(dirname, "./lb", @@ -27,8 +28,8 @@ namespace paddle { NativeConfig GetConfig() { NativeConfig config; // config.model_dir = FLAGS_dirname; - config.prog_file= "lb/__model__"; - config.param_file= "lb/__params__"; + config.prog_file= "hs_lb_without_bn/__model__"; + config.param_file= "hs_lb_without_bn/__params__"; config.fraction_of_gpu_memory = 0.8; config.use_gpu = true; config.device = 0; @@ -44,6 +45,7 @@ double time_diff(Time t1, Time t2) { return counter.count() / 1000.0; } + void test_naive(int batch_size){ NativeConfig config = GetConfig(); auto predictor = CreatePaddlePredictor(config); @@ -88,10 +90,9 @@ void test_naive(int batch_size){ PaddleTensor tensor_out; std::vector outputs(1, tensor_out); - predictor->Run(paddle_tensor_feeds, &outputs, batch_size); + // predictor->Run(paddle_tensor_feeds, &outputs, batch_size); std::cout << "start predict123:" << std::endl; auto time1 = time(); - for(size_t i = 0; i < 1; i++) { predictor->Run(paddle_tensor_feeds, &outputs, batch_size); diff --git a/paddle/fluid/operators/fetch_op.cc b/paddle/fluid/operators/fetch_op.cc index c197b45e8196a47def6465128e8ca39d8daefed6..6c19494939cc04cc3a026f6f81e8976090638a7e 100644 --- a/paddle/fluid/operators/fetch_op.cc +++ b/paddle/fluid/operators/fetch_op.cc @@ -42,6 +42,8 @@ class FetchOp : public framework::OperatorBase { "Cannot find out_var in scope, out_var_name is %s", out_name); + VLOG(3) << "fetch_var ptr " << fetch_var << " is " << (fetch_var == nullptr); + VLOG(3) << "out_var ptr " << out_var << " is " << (out_var == nullptr); auto col = static_cast(Attr("col")); auto *fetch_list = out_var->GetMutable(); diff --git a/paddle/fluid/operators/load_combine_op.cc b/paddle/fluid/operators/load_combine_op.cc index ccc497affbdd27061a186a87c38022870365939b..14c0a464543ee2206201577cf1526de53336e424 100644 --- a/paddle/fluid/operators/load_combine_op.cc +++ b/paddle/fluid/operators/load_combine_op.cc @@ -67,7 +67,11 @@ class LoadCombineOp : public framework::OperatorBase { framework::TensorCopy(*tensor, platform::CPUPlace(), dev_ctx, &check); float sum = .0; for(size_t i=0; i < check.numel(); ++i) { + if(std::type_index(check.type()) == std::type_index(typeid(int64_t))) { + sum += static_cast(check.data()[i]); + } else { sum += check.data()[i]; + } } VLOG(3) << "sum result" << sum; auto in_dtype = framework::ToDataType(tensor->type());