Conversation
…instantiation within tensor functions
There was a problem hiding this comment.
Cpp-linter Review
Used clang-tidy v16.0.6
Only 50 out of 58 clang-tidy concerns fit within this pull request's diff.
Have any feedback or feature suggestions? Share it here.
| ret.setTensor(tensor); | ||
|
|
||
| return ret; | ||
| return Tensor(tensor); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/tensor.hpp:438:16: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(tensor);
^| } | ||
|
|
||
| protected: | ||
| torch::Tensor _tensor; |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/tensor.hpp:509:19: warning: [cppcoreguidelines-non-private-member-variables-in-classes]
member variable '_tensor' has protected visibility
torch::Tensor _tensor;
^
nuTens/tensors/torch-tensor.cpp
Outdated
|
|
||
| Tensor ret; | ||
| ret.setTensor(torch::eye(n, torch::TensorOptions() | ||
| return Tensor(torch::eye(n, torch::TensorOptions() |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:26:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(torch::eye(n, torch::TensorOptions()
^
nuTens/tensors/torch-tensor.cpp
Outdated
|
|
||
| Tensor ret; | ||
| ret.setTensor(torch::rand(c10::IntArrayRef(shape), torch::TensorOptions() | ||
| return Tensor(torch::rand(c10::IntArrayRef(shape), torch::TensorOptions() |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:37:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(torch::rand(c10::IntArrayRef(shape), torch::TensorOptions()
^
nuTens/tensors/torch-tensor.cpp
Outdated
| ret._dType = diag._dType; | ||
| ret._device = diag._device; | ||
| return ret; | ||
| return Tensor(torch::diag(diag._tensor)); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:48:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(torch::diag(diag._tensor));
^
nuTens/tensors/torch-tensor.cpp
Outdated
| Tensor ret; | ||
| ret.setTensor(_tensor.grad()); | ||
| return ret; | ||
| return Tensor(_tensor.grad()); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:572:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(_tensor.grad());
^| return Tensor(_tensor.grad()); | ||
| } | ||
|
|
||
| Tensor Tensor::sin(const Tensor &t) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:575:34: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::sin(const Tensor &t)
^
nuTens/tensors/torch-tensor.cpp
Outdated
| Tensor ret; | ||
| ret.setTensor(torch::sin(t._tensor)); | ||
| return ret; | ||
| return Tensor(torch::sin(t._tensor)); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:579:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(torch::sin(t._tensor));
^| return Tensor(torch::sin(t._tensor)); | ||
| } | ||
|
|
||
| Tensor Tensor::cos(const Tensor &t) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:582:34: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::cos(const Tensor &t)
^
nuTens/tensors/torch-tensor.cpp
Outdated
| Tensor ret; | ||
| ret.setTensor(torch::cos(t._tensor)); | ||
| return ret; | ||
| return Tensor(torch::cos(t._tensor)); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:586:12: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(torch::cos(t._tensor));
^|
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cpp-linter Review
Used clang-tidy v16.0.6
Only 14 out of 21 clang-tidy concerns fit within this pull request's diff.
Have any feedback or feature suggestions? Share it here.
| ret.setTensor(tensor); | ||
|
|
||
| return ret; | ||
| return Tensor(tensor); |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/tensor.hpp:438:16: warning: [modernize-return-braced-init-list]
avoid repeating the return type from the declaration; use a braced initializer list instead
return Tensor(tensor);
^| } | ||
|
|
||
| protected: | ||
| torch::Tensor _tensor; |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/tensor.hpp:509:19: warning: [cppcoreguidelines-non-private-member-variables-in-classes]
member variable '_tensor' has protected visibility
torch::Tensor _tensor;
^| return {torch::matmul(t1._tensor, t2._tensor)}; | ||
| } | ||
|
|
||
| Tensor Tensor::outer(const Tensor &t1, const Tensor &t2) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:238:36: warning: [readability-identifier-length]
parameter name 't1' is too short, expected at least 3 characters
Tensor Tensor::outer(const Tensor &t1, const Tensor &t2)
^clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:238:54: warning: [readability-identifier-length]
parameter name 't2' is too short, expected at least 3 characters
Tensor Tensor::outer(const Tensor &t1, const Tensor &t2)
^| return {torch::outer(t1._tensor, t2._tensor)}; | ||
| } | ||
|
|
||
| Tensor Tensor::mul(const Tensor &t1, const Tensor &t2) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:245:34: warning: [readability-identifier-length]
parameter name 't1' is too short, expected at least 3 characters
Tensor Tensor::mul(const Tensor &t1, const Tensor &t2)
^clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:245:52: warning: [readability-identifier-length]
parameter name 't2' is too short, expected at least 3 characters
Tensor Tensor::mul(const Tensor &t1, const Tensor &t2)
^| return {torch::mul(t1._tensor, t2._tensor)}; | ||
| } | ||
|
|
||
| Tensor Tensor::div(const Tensor &t1, const Tensor &t2) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:252:34: warning: [readability-identifier-length]
parameter name 't1' is too short, expected at least 3 characters
Tensor Tensor::div(const Tensor &t1, const Tensor &t2)
^clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:252:52: warning: [readability-identifier-length]
parameter name 't2' is too short, expected at least 3 characters
Tensor Tensor::div(const Tensor &t1, const Tensor &t2)
^| Tensor ret; | ||
| ret.setTensor(torch::transpose(t._tensor, dim1, dim2)); | ||
| return ret; | ||
| return {torch::transpose(t._tensor, dim1, dim2)}; |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:284:13: warning: [readability-suspicious-call-argument]
2nd argument 'dim1' (passed to 'dim0') looks like it might be swapped with the 3rd, 'dim2' (passed to 'dim1')
return {torch::transpose(t._tensor, dim1, dim2)};
^ ~~~~ ~~~~
/home/runner/.local/lib/python3.10/site-packages/torch/include/ATen/ops/transpose.h:26:19: note: in the call to 'transpose', declared here
inline at::Tensor transpose(const at::Tensor & self, int64_t dim0, int64_t dim1) {
^ ~~~~ ~~~~| return {torch::transpose(t._tensor, dim1, dim2)}; | ||
| } | ||
|
|
||
| Tensor Tensor::scale(const Tensor &t, float s) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:287:36: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::scale(const Tensor &t, float s)
^clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:287:45: warning: [readability-identifier-length]
parameter name 's' is too short, expected at least 3 characters
Tensor Tensor::scale(const Tensor &t, float s)
^| return {torch::multiply(t._tensor, s)}; | ||
| } | ||
|
|
||
| Tensor Tensor::scale(const Tensor &t, double s) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:294:36: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::scale(const Tensor &t, double s)
^clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:294:46: warning: [readability-identifier-length]
parameter name 's' is too short, expected at least 3 characters
Tensor Tensor::scale(const Tensor &t, double s)
^| return {_tensor.grad()}; | ||
| } | ||
|
|
||
| Tensor Tensor::sin(const Tensor &t) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:575:34: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::sin(const Tensor &t)
^| return {torch::sin(t._tensor)}; | ||
| } | ||
|
|
||
| Tensor Tensor::cos(const Tensor &t) |
There was a problem hiding this comment.
clang-tidy diagnostic
nuTens/tensors/torch-tensor.cpp:582:34: warning: [readability-identifier-length]
parameter name 't' is too short, expected at least 3 characters
Tensor Tensor::cos(const Tensor &t)
^
Add constructor taking a pytorch tensor so we can simplify the internal creation of tensors in e.g. arithmetic functions