refactor: address cppcheck performance warnings and enable performance static analysis
This commit is contained in:
@@ -25,7 +25,7 @@ repos:
|
||||
language: system
|
||||
types_or: [c++, c]
|
||||
args: [
|
||||
"--enable=warning,portability",
|
||||
"--enable=warning,portability,performance",
|
||||
"--suppress=missingIncludeSystem",
|
||||
"--suppress=unusedFunction",
|
||||
"--suppress=normalCheckLevelMaxBranches",
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
struct TinyNet : torch::nn::Module {
|
||||
torch::nn::Linear fc1{nullptr}, fc2{nullptr};
|
||||
|
||||
TinyNet() {
|
||||
fc1 = register_module("fc1", torch::nn::Linear(10, 32));
|
||||
fc2 = register_module("fc2", torch::nn::Linear(32, 1));
|
||||
}
|
||||
TinyNet()
|
||||
: fc1(register_module("fc1", torch::nn::Linear(10, 32))),
|
||||
fc2(register_module("fc2", torch::nn::Linear(32, 1))) {}
|
||||
|
||||
torch::Tensor forward(torch::Tensor x) {
|
||||
x = torch::relu(fc1->forward(x));
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
struct RegressionNet : torch::nn::Module {
|
||||
torch::nn::Linear fc1{nullptr}, fc2{nullptr};
|
||||
|
||||
RegressionNet() {
|
||||
fc1 = register_module("fc1", torch::nn::Linear(1, 16));
|
||||
fc2 = register_module("fc2", torch::nn::Linear(16, 1));
|
||||
}
|
||||
RegressionNet()
|
||||
: fc1(register_module("fc1", torch::nn::Linear(1, 16))),
|
||||
fc2(register_module("fc2", torch::nn::Linear(16, 1))) {}
|
||||
|
||||
torch::Tensor forward(torch::Tensor x) {
|
||||
x = torch::tanh(fc1->forward(x));
|
||||
|
||||
@@ -86,13 +86,11 @@ FCESOptimizer::FCESOptimizer(std::vector<torch::Tensor> params,
|
||||
population_(config_.population_size, 10000, EliteStrategy::Cumulative,
|
||||
false, false, false, false, false,
|
||||
config_.direct_construction, config_.use_banach_fission),
|
||||
fitness_engine_(config_.grokking_coefficient) {
|
||||
|
||||
evolution_manager_ = std::make_unique<EvolutionManager>(
|
||||
population_, 50, config_.auto_population, config_.direct_construction);
|
||||
|
||||
spectral_sensor_ = std::make_unique<SpectralSensor>();
|
||||
|
||||
fitness_engine_(config_.grokking_coefficient),
|
||||
evolution_manager_(std::make_unique<EvolutionManager>(
|
||||
population_, 50, config_.auto_population,
|
||||
config_.direct_construction)),
|
||||
spectral_sensor_(std::make_unique<SpectralSensor>()) {
|
||||
// Initial RAM backup
|
||||
backup_to_ram();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user