The following issues were found
caffe2/operators/boolean_unmask_ops_test.cc
1 issues
Line: 37
// values2: [ 1.0 ]
//
// Expected Output: [ 1.0 ]
TEST(BooleanUnmaskTest, Test) {
Workspace ws;
OperatorDef def;
def.set_name("test");
def.set_type("BooleanUnmask");
Reported by Cppcheck.
caffe2/operators/batch_permutation_op_gpu_test.cc
1 issues
Line: 245
} // namespace
TEST(BatchPermutationTest, CHECKCPUGPUEqualGenericDimension) {
auto t0 = std::chrono::high_resolution_clock::now();
int batch_size = 8;
int max_dimension = 6;
vector<int64_t> shape = vector<int64_t>{batch_size};
Reported by Cppcheck.
caffe2/operators/batch_matmul_op_test.cc
1 issues
Line: 60
OperatorDef def_;
};
TEST_F(BatchMatMulOpTest, BatchMatMulOpNormalTest) {
AddConstInput(std::vector<int64_t>{3, 5, 10}, 1.0f, "A");
AddConstInput(std::vector<int64_t>{3, 10, 6}, 1.0f, "B");
std::unique_ptr<OperatorBase> op(CreateOperator(def_, &ws_));
ASSERT_NE(nullptr, op);
ASSERT_TRUE(op->Run());
Reported by Cppcheck.
caffe2/operators/batch_matmul_op_gpu_test.cc
1 issues
Line: 63
OperatorDef def_;
};
TEST_F(BatchMatMulOpGPUTest, BatchMatMulOpGPUNormalTest) {
if (!HasCudaGPU()) {
return;
}
AddConstInput(std::vector<int64_t>{3, 5, 10}, 1.0f, "A");
AddConstInput(std::vector<int64_t>{3, 10, 6}, 1.0f, "B");
Reported by Cppcheck.
caffe2/operators/batch_matmul_op.h
1 issues
Line: 166
Column: 42
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
T* Y_data = Y->template mutable_data<T>();
const int batch_dim = ndim - 2;
const bool is_broadcast_dims = !std::equal(
A_broadcast_dims.cbegin(),
A_broadcast_dims.cbegin() + batch_dim,
B_broadcast_dims.cbegin());
if (is_broadcast_dims) {
CAFFE_ENFORCE(broadcast_);
Reported by FlawFinder.
caffe2/onnx/device.cc
1 issues
Line: 15
Column: 15
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)
Device::Device(const std::string &spec) {
auto pos = spec.find_first_of(':');
type = kDeviceMap.at(spec.substr(0, pos - 1));
device_id = atoi(spec.substr(pos + 1).c_str());
}
}}
Reported by FlawFinder.
caffe2/observers/time_observer_test.cc
1 issues
Line: 55
}
} // namespace
TEST(TimeObserverTest, Test3Seconds) {
Workspace ws;
ws.CreateBlob("in");
NetDef net_def;
unique_ptr<NetBase> net(CreateNetTestHelper(&ws));
auto net_ob = std::make_unique<TimeObserver>(net.get());
Reported by Cppcheck.
caffe2/mpi/mpi_test.cc
1 issues
Line: 44
}
)NET";
TEST(MPITest, TestMPIBroadcast) {
NetDef net_def;
CHECK(TextFormat::ParseFromString(
string(kBcastNet), &net_def));
// Let's set the network's constant fill value to be the mpi rank.
auto* arg = net_def.mutable_op(1)->mutable_arg(1);
Reported by Cppcheck.
.jenkins/pytorch/perf_test/update_commit_hash.py
1 issues
Line: 1
Column: 1
import sys
import json
data_file_path = sys.argv[1]
commit_hash = sys.argv[2]
with open(data_file_path) as data_file:
data = json.load(data_file)
Reported by Pylint.
caffe2/mpi/mpi_gpu_test.cc
1 issues
Line: 48
}
)NET";
TEST(MPITest, TestMPIBroadcast) {
NetDef net_def;
CHECK(TextFormat::ParseFromString(
string(kBcastNet), &net_def));
// Let's set the network's constant fill value to be the mpi rank.
auto* arg = net_def.mutable_op(1)->mutable_arg(1);
Reported by Cppcheck.