提交 6cd46fe5 编写于 作者: X Xiangquan Xiao 提交者: Kecheng Xu

Robot: Code clean with clang-format.

上级 64516a26
......@@ -18,14 +18,14 @@
#include <dirent.h>
#include <errno.h>
#include <glob.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <glob.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stddef.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fstream>
#include <string>
......@@ -331,7 +331,7 @@ std::string GetCurrentPath() {
return getcwd(tmp, sizeof(tmp)) ? std::string(tmp) : std::string("");
}
bool GetType(const string& filename, FileType* type) {
bool GetType(const string &filename, FileType *type) {
struct stat stat_buf;
if (lstat(filename.c_str(), &stat_buf) != 0) {
return false;
......@@ -347,7 +347,7 @@ bool GetType(const string& filename, FileType* type) {
return true;
}
bool DeleteFile(const string& filename) {
bool DeleteFile(const string &filename) {
if (!PathExists(filename)) {
return true;
}
......@@ -362,12 +362,12 @@ bool DeleteFile(const string& filename) {
}
return true;
}
DIR* dir = opendir(filename.c_str());
DIR *dir = opendir(filename.c_str());
if (dir == nullptr) {
AWARN << "failed to opendir: " << filename;
return false;
}
dirent* dir_info = nullptr;
dirent *dir_info = nullptr;
while ((dir_info = readdir(dir)) != nullptr) {
if (strcmp(dir_info->d_name, ".") == 0 ||
strcmp(dir_info->d_name, "..") == 0) {
......@@ -390,7 +390,7 @@ bool DeleteFile(const string& filename) {
return true;
}
bool CreateDir(const string& dir) {
bool CreateDir(const string &dir) {
int ret = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
if (ret != 0) {
AWARN << "failed to create dir. [dir: " << dir
......
......@@ -195,11 +195,11 @@ std::string GetFileName(const std::string &path,
std::string GetCurrentPath();
// delete file including file or directory
bool DeleteFile(const std::string& filename);
bool DeleteFile(const std::string &filename);
bool GetType(const std::string& filename, FileType* type);
bool GetType(const std::string &filename, FileType *type);
bool CreateDir(const std::string& dir);
bool CreateDir(const std::string &dir);
} // namespace common
} // namespace cyber
} // namespace apollo
......
......@@ -104,8 +104,8 @@ bool DarkSCNNLaneDetector::Init(const LaneDetectorInitOptions &options) {
const auto net_param = darkscnn_param_.net_param();
net_inputs_.push_back(net_param.input_blob());
net_outputs_.push_back(net_param.seg_blob());
if (model_param.model_type() == "CaffeNet" &&
net_param.has_vpt_blob() && net_param.vpt_blob().size() > 0) {
if (model_param.model_type() == "CaffeNet" && net_param.has_vpt_blob() &&
net_param.vpt_blob().size() > 0) {
net_outputs_.push_back(net_param.vpt_blob());
}
......
......@@ -17,8 +17,8 @@
#include "modules/perception/inference/inference_factory.h"
#include "modules/perception/inference/caffe/caffe_net.h"
#include "modules/perception/inference/tensorrt/rt_net.h"
#include "modules/perception/inference/paddlepaddle/paddle_net.h"
#include "modules/perception/inference/tensorrt/rt_net.h"
namespace apollo {
namespace perception {
......
......@@ -27,8 +27,9 @@ namespace inference {
PaddleNet::PaddleNet(const std::string &model_file,
const std::string &param_file,
const std::vector<std::string> &outputs)
: model_file_(model_file), param_file_(param_file), output_names_(outputs)
{}
: model_file_(model_file),
param_file_(param_file),
output_names_(outputs) {}
bool PaddleNet::Init(const std::map<std::string, std::vector<int>> &shapes) {
paddle::AnalysisConfig config;
......@@ -55,9 +56,7 @@ bool PaddleNet::Init(const std::map<std::string, std::vector<int>> &shapes) {
input_shape = name_shape.second;
}
/////////////////
int input_num = std::accumulate(input_shape.begin(),
input_shape.end(),
1,
int input_num = std::accumulate(input_shape.begin(), input_shape.end(), 1,
std::multiplies<int>());
std::vector<std::vector<float>> input_data(1);
input_data[0].resize(input_num);
......@@ -67,7 +66,7 @@ bool PaddleNet::Init(const std::map<std::string, std::vector<int>> &shapes) {
// Prepare inputs
auto input_names = predictor_->GetInputNames();
int index = 0;
for (auto& name : input_names) {
for (auto &name : input_names) {
auto input_t = predictor_->GetInputTensor(name);
input_t->Reshape(input_shape);
input_t->copy_from_cpu(input_data[index].data());
......@@ -120,13 +119,12 @@ bool PaddleNet::reshape() {
if (paddle_blob != nullptr && blob != nullptr) {
paddle_blob->Reshape(blob->shape());
std::vector<int> paddle_blob_shape = paddle_blob->shape();
int count = std::accumulate(paddle_blob_shape.begin(),
paddle_blob_shape.end(),
1,
int count =
std::accumulate(paddle_blob_shape.begin(), paddle_blob_shape.end(), 1,
std::multiplies<int>());
cudaMemcpy(paddle_blob->mutable_data<float>(paddle::PaddlePlace::kGPU),
blob->gpu_data(),
count * sizeof(float), cudaMemcpyDeviceToDevice);
blob->gpu_data(), count * sizeof(float),
cudaMemcpyDeviceToDevice);
}
}
......@@ -160,9 +158,8 @@ void PaddleNet::Infer() {
blob->Reshape(paddle_blob->shape());
// TODO(KaWai) : use the output_size as the count;
std::vector<int> paddle_blob_shape = paddle_blob->shape();
int count = std::accumulate(paddle_blob_shape.begin(),
paddle_blob_shape.end(),
1,
int count =
std::accumulate(paddle_blob_shape.begin(), paddle_blob_shape.end(), 1,
std::multiplies<int>());
// int output_size;
// paddle::PaddlePlace* place;
......@@ -176,21 +173,19 @@ void PaddleNet::Infer() {
bool PaddleNet::shape(const std::string &name, std::vector<int> *res) {
bool in_input = false;
bool in_output = false;
if (std::find(input_names_.begin(),
input_names_.end(),
name) != input_names_.end()) {
if (std::find(input_names_.begin(), input_names_.end(), name) !=
input_names_.end()) {
in_input = true;
} else if (std::find(output_names_.begin(),
output_names_.end(),
name) != output_names_.end()) {
} else if (std::find(output_names_.begin(), output_names_.end(), name) !=
output_names_.end()) {
in_output = true;
}
if (~in_input && ~in_output) {
return false;
}
auto blob = in_input? predictor_->GetInputTensor(name_map_[name]):
predictor_->GetOutputTensor(name_map_[name]);
auto blob = in_input ? predictor_->GetInputTensor(name_map_[name])
: predictor_->GetOutputTensor(name_map_[name]);
if (blob == nullptr) {
return false;
}
......
......@@ -16,15 +16,15 @@
#pragma once
#include <chrono>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <numeric>
#include <iostream>
#include <chrono>
#include <unordered_map>
#include "paddle/paddle_inference_api.h"
......@@ -89,8 +89,7 @@ class PaddleNet : public Inference {
{"category_score", "save_infer_model/scale_2"},
{"instance_pt", "save_infer_model/scale_3"},
{"heading_pt", "save_infer_model/scale_4"},
{"height_pt", "save_infer_model/scale_5"}
};
{"height_pt", "save_infer_model/scale_5"}};
};
} // namespace inference
......
......@@ -15,9 +15,9 @@
*****************************************************************************/
#include "modules/perception/lidar/tools/exporter/msg_exporter.h"
#include <pcl/io/pcd_io.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <memory>
#include <opencv2/opencv.hpp>
#include <vector>
#include "cyber/common/file.h"
#include "cyber/common/log.h"
......
......@@ -16,8 +16,8 @@
#pragma once
#include <Eigen/Dense>
#include <string>
#include <memory>
#include <string>
#include <vector>
#include "cyber/cyber.h"
#include "modules/drivers/proto/pointcloud.pb.h"
......
......@@ -14,12 +14,12 @@
* limitations under the License.
*****************************************************************************/
#include "modules/perception/lidar/tools/exporter/msg_exporter.h"
#include <fstream>
#include <memory>
#include "cyber/common/log.h"
#include "cyber/cyber.h"
#include "modules/common/util/string_util.h"
#include "modules/perception/lidar/tools/exporter/msg_exporter.h"
namespace apollo {
namespace perception {
......@@ -68,8 +68,8 @@ int main(int argc, char** argv) {
}
// apollo::cyber::Logger::Init(argv[0]);
apollo::cyber::Init(argv[0]); // cybertron init function
std::shared_ptr<apollo::cyber::Node>
node(apollo::cyber::CreateNode("export_node"));
std::shared_ptr<apollo::cyber::Node> node(
apollo::cyber::CreateNode("export_node"));
if (!node) {
std::cout << "Failed to create export node." << std::endl;
return -1;
......
......@@ -534,8 +534,7 @@ bool PathBoundsDecider::SearchPullOverPosition(
pull_over_space_length) {
int j = i;
bool is_feasible_window = true;
while (j >= 0 &&
std::get<0>(path_bound[i]) - std::get<0>(path_bound[j]) <
while (j >= 0 && std::get<0>(path_bound[i]) - std::get<0>(path_bound[j]) <
pull_over_space_length) {
double curr_s = std::get<0>(path_bound[j]);
double curr_right_bound = std::fabs(std::get<1>(path_bound[j]));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册