Skip to content

Commit

Permalink
fix non-pch compilation and do the linters bidding
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanwm committed Sep 18, 2024
1 parent 062a9a6 commit 3e7f8a1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions nuTens/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
add_library(logging logging.hpp)
target_link_libraries(logging spdlog::spdlog)
set_target_properties(logging PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(logging PUBLIC "${SPDLOG_INCLUDE_DIRS}")

set( NT_LOG_LEVEL "INFO" CACHE STRING "the level of detail to log to the console" )

Expand Down
2 changes: 2 additions & 0 deletions nuTens/tensors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ IF(NT_USE_PCH)
target_link_libraries(tensor PUBLIC nuTens-pch)

ELSE()
target_link_libraries(tensor PUBLIC logging)

IF(TORCH_FOUND)

target_link_libraries(tensor PUBLIC "${TORCH_LIBRARIES}")
Expand Down
4 changes: 4 additions & 0 deletions nuTens/tensors/dtypes.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#if USE_PYTORCH
#include <torch/torch.h>
#endif

/*!
* @file dtypes.hpp
* @brief Defines various datatypes used in the project
Expand Down
8 changes: 5 additions & 3 deletions nuTens/tensors/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <iostream>
#include <map>
#include <nuTens/instrumentation.hpp>
#include <nuTens/logging.hpp>
#include <nuTens/tensors/dtypes.hpp>
#include <variant>
#include <vector>
Expand Down Expand Up @@ -378,14 +379,14 @@ class Tensor
{
NT_PROFILE();

_tensor = tensor;
_tensor = std::move(tensor);
_dType = NTdtypes::invScalarTypeMap.at(tensor.scalar_type());

Check warning on line 383 in nuTens/tensors/tensor.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

nuTens/tensors/tensor.hpp:383:48 [bugprone-use-after-move]

'tensor' used after it was moved

Check warning on line 383 in nuTens/tensors/tensor.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

nuTens/tensors/tensor.hpp:383:48 [clang-analyzer-cplusplus.Move]

Method called on moved-from object 'tensor'
_device = NTdtypes::invDeviceTypeMap.at(tensor.device().type());
}

/// Utility function to convert from a vector of ints to a vector of a10 tensor indices, which is needed for
/// accessing values of a tensor.
inline std::vector<at::indexing::TensorIndex> convertIndices(const std::vector<int> &indices) const
[[nodiscard]] inline std::vector<at::indexing::TensorIndex> convertIndices(const std::vector<int> &indices) const

Check warning on line 389 in nuTens/tensors/tensor.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

nuTens/tensors/tensor.hpp:389:65 [readability-convert-member-functions-to-static]

method 'convertIndices' can be made static
{
NT_PROFILE();

Expand All @@ -401,7 +402,8 @@ class Tensor

/// Utility function to convert from a vector of ints to a vector of a10 tensor indices, which is needed for
/// accessing values of a tensor.
inline std::vector<at::indexing::TensorIndex> convertIndices(const std::vector<Tensor::indexType> &indices) const
[[nodiscard]] inline std::vector<at::indexing::TensorIndex> convertIndices(

Check warning on line 405 in nuTens/tensors/tensor.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

nuTens/tensors/tensor.hpp:405:65 [readability-convert-member-functions-to-static]

method 'convertIndices' can be made static
const std::vector<Tensor::indexType> &indices) const
{
NT_PROFILE();

Expand Down
6 changes: 3 additions & 3 deletions python/pyNuTens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

namespace py = pybind11;

void initTensor(py::module &);
void initPropagator(py::module &);
void initDtypes(py::module &);
void initTensor(py::module & /*m*/);
void initPropagator(py::module & /*m*/);
void initDtypes(py::module & /*m*/);

// initialise the top level module "pyNuTens"
PYBIND11_MODULE(pyNuTens, m)

Check warning on line 22 in python/pyNuTens.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

python/pyNuTens.cpp:22:1 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'pybind11_module_def_pyNuTens' is non-const and globally accessible, consider making it const

Check warning on line 22 in python/pyNuTens.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

python/pyNuTens.cpp:22:1 [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic
Expand Down

0 comments on commit 3e7f8a1

Please sign in to comment.