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