The following issues were found
caffe2/quantization/server/fbgemm_fp16_pack_op.h
1 issues
Line: 70
Column: 7
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
vector<fbgemm::float16> src_mat(resultPtr->matSize());
fbgemm::float16* pmat = resultPtr->pmat();
memcpy(
src_mat.data(), pmat, resultPtr->matSize() * sizeof(fbgemm::float16));
resultPtr->unpackFromSrc(fbgemm::matrix_op_t::Transpose, src_mat.data());
}
auto* Y =
Reported by FlawFinder.
test/cpp/tensorexpr/test_boundsinference.cpp
1 issues
Line: 43
}
}
TEST(BoundsInference, _1) {
// Verify that bounds inference works for the following example:
// for i in 0..100:
// b[i] = a[i]
// For this loop bounds inference should yield the following:
// {{b, kStore, 0, 99}, {a, kLoad, 0, 99}}
Reported by Cppcheck.
test/cpp/tensorexpr/test_aten.cpp
1 issues
Line: 17
using namespace torch::jit::tensorexpr;
TEST(ATen, _cast_Float) {
KernelScope kernel_scope;
const int kTotalSize = 128;
Placeholder a_buf(BufHandle("A", {ExprHandle(kTotalSize)}, kInt));
Placeholder b_buf(BufHandle("B", {ExprHandle(kTotalSize)}, kFloat));
Reported by Cppcheck.
test/cpp/rpc/test_e2e_tensorpipe.cpp
1 issues
Line: 51
// End to end training loop test in C++ so that we can run LSAN on this test to
// catch memory leaks. Enabling LSAN with python multiprocessing has been
// challenging and we don't have a good solution yet.
TEST_F(TestE2ETensorPipe, TestTrainingLoop) {
runTrainingLoop();
// Ensure the tensorpipe internal state is cleared up.
auto tensorpipeAgent = std::static_pointer_cast<TensorPipeAgent>(rpcAgent);
// Shutdown RPC agent for all RPCs to clean up.
Reported by Cppcheck.
test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp
1 issues
Line: 36
}
} // namespace
TEST(MobileProfiler, ModuleHierarchy) {
std::string filePath(__FILE__);
auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1);
testModelFile.append("to_be_profiled_module.ptl");
std::vector<IValue> inputs;
Reported by Cppcheck.
caffe2/quantization/server/elementwise_sum_benchmark.cc
1 issues
Line: 11
Column: 24
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
using namespace std;
int main(int argc, const char* argv[]) {
int LEN = argc > 1 ? atoi(argv[1]) : 65536;
vector<uint8_t> a(LEN), b(LEN), c_avx2(LEN), c_avx512(LEN);
for (int i = 0; i < LEN; ++i) {
a[i] = i % 256;
b[i] = (i * 2) % 256;
Reported by FlawFinder.
caffe2/quantization/server/batch_permutation_dnnlowp_op.cc
1 issues
Line: 44
Column: 10
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
for (int i = 0; i < N; ++i) {
int origIdx = i * K;
int permuteIdx = indices_data[i] * K;
std::memcpy(Y_data + origIdx, X_data + permuteIdx, K * sizeof(T));
}
// Even if there is a pre-chosen quantization parameters for the output,
// it is ignored because batch permutation output quantization should be same
// as the input.
Reported by FlawFinder.