Skip to content

Commit

Permalink
[ Bug ] Fix coverity issues
Browse files Browse the repository at this point in the history
- Fix non-const variables to const variables since their value is never changed in actual practice
- Use const auto & to avoid object copy

Resolves:
```
non-const type variable, but its value is never changed.
auto_causes_copy
```

**Self evaluation:**
1. Build test:     [X]Passed [ ]Failed [ ]Skipped
2. Run test:     [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: skykongkong8 <[email protected]>
  • Loading branch information
skykongkong8 committed Jan 31, 2024
1 parent e93fc05 commit bff8372
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion nntrainer/tensor/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ std::vector<Tensor *> Manager::requestWeightOptimizerVariables(
const std::vector<TensorDim> &dims, const std::string &name,
const TensorLifespan &lifespan, bool is_grad_clip,
Tensor::Initializer initializer) {
auto const exec_order = weight_pool.getExecutionOrder(name);

std::vector<Tensor *> ret;
ret.reserve(dims.size());
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/optimized_v2_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ size_t OptimizedV2Planner::planLayout(
#endif
for (auto &req : wgrad_requests) {
for (unsigned int idx = 0; idx < wgrad_sorted_req.size(); idx++) {
auto const sr = wgrad_sorted_req[idx];
const auto &sr = wgrad_sorted_req[idx];
bool merge = true;
if (sr.mem_req->size >= req.size) {
for (auto &interval : sr.start_end) {
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/task_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TaskExecutor::TaskExecutor(const std::string &n) :
auto &task_info = task_queue.front();
lk.unlock();

auto id = std::get<int>(task_info);
const auto &id = std::get<int>(task_info);
auto callback = std::get<CompleteCallback>(task_info);

auto status = worker(task_info);
Expand Down

0 comments on commit bff8372

Please sign in to comment.