The following issues were found
benchmarks/instruction_counts/definitions/standard.py
1 issues
Line: 221
Column: 3
(Setup.TRIVIAL_2D, True, ("Sigmoid()",) * 2),
(Setup.TRIVIAL_4D, True, ("Linear(4, 2)",) * 2),
# TODO: LSTM can't be TorchScript'd
(Setup.TRIVIAL_3D, False, ("LSTM(4, 2)",) * 2),
)
},
"training": {
Reported by Pylint.
benchmarks/instruction_counts/definitions/setup.py
1 issues
Line: 46
Column: 1
))
class Setup(enum.Enum):
TRIVIAL_2D = _TRIVIAL_2D
TRIVIAL_3D = _TRIVIAL_3D
TRIVIAL_4D = _TRIVIAL_4D
TRAINING = _TRAINING
Reported by Pylint.
benchmarks/instruction_counts/core/types.py
1 issues
Line: 10
Column: 1
# =============================================================================
# == Benchmark schema =========================================================
# =============================================================================
""" (There is a TL;DR at the end for ad-hoc benchmarks.)
The end state for representing a benchmark is:
```
Tuple[
Tuple[
Tuple[str, ...], # Primary key
Reported by Pylint.
aten/src/THC/generic/THCTensorMathPairwise.h
1 issues
Line: 6
Column: 5
CWE codes:
126
Suggestion:
This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it
#else
TORCH_CUDA_CU_API int THCTensor_(
equal)(THCState* state, THCTensor* self, THCTensor* src);
#if !defined(THC_REAL_IS_BOOL)
TORCH_CUDA_CU_API void THCTensor_(
mul)(THCState* state, THCTensor* self, THCTensor* src, scalar_t value);
Reported by FlawFinder.
aten/src/THC/generic/THCTensor.cpp
1 issues
Line: 466
Column: 10
CWE codes:
134
Suggestion:
Use a constant for the format specification
int i;
for(i = 0; i < tensor->dim(); i++) {
if(n >= L) break;
n += snprintf(str+n, L-n, "%" PRId64, tensor->size(i));
if(i < tensor->dim()-1) {
n += snprintf(str+n, L-n, " x ");
}
}
if(n < L - 2) {
Reported by FlawFinder.
aten/src/THC/THCTensor.h
1 issues
Line: 13
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
#define THC_DESC_BUFF_LEN 64
typedef struct TORCH_CUDA_CU_API THCDescBuff {
char str[THC_DESC_BUFF_LEN];
} THCDescBuff;
#include <THC/generic/THCTensor.h>
#include <THC/THCGenerateAllTypes.h>
Reported by FlawFinder.
aten/src/ATen/test/vulkan_api_test.cpp
1 issues
Line: 87
ASSERT_TRUE(check);
}
TEST(VulkanAPITest, add) {
if (!at::is_vulkan_available()) {
return;
}
const auto a_cpu = at::rand({11, 7, 139, 109}, at::device(at::kCPU).dtype(at::kFloat));
Reported by Cppcheck.
aten/src/ATen/test/vmap_test.cpp
1 issues
Line: 64
return result;
}
TEST(VmapTest, TestBatchedTensorMaxLevel) {
{
// Should not throw
auto tensor = ones({2, 3, 4});
makeBatched(ones({2, 3, 4}), {{/*lvl*/kVmapNumLevels - 1, /*dim*/0}});
}
Reported by Cppcheck.
aten/src/ATen/test/type_test.cpp
1 issues
Line: 30
EXPECT_EQ(intType->annotation_str(printer), intType->annotation_str());
}
TEST(TypeCustomPrinter, ContainedTypes) {
TypePrinter printer =
[](const ConstTypePtr& t) -> c10::optional<std::string> {
if (auto tensorType = t->cast<TensorType>()) {
return "CustomTensor";
}
Reported by Cppcheck.
aten/src/ATen/test/scalar_tensor_test.cpp
1 issues
Line: 131
Column: 28
CWE codes:
126
Suggestion:
This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it
if (t.numel() != 0) {
ASSERT_EQ(t.sum(0).dim(), std::max<int64_t>(t.dim() - 1, 0));
} else {
ASSERT_TRUE(t.sum(0).equal(at::zeros({}, T)));
}
// reduce (with dimension argument and with 2 return arguments)
if (t.numel() != 0) {
auto ret = t.min(0);
Reported by FlawFinder.