diff --git a/eisgenerator/model.h b/eisgenerator/model.h index f4f4541dafcd25bb5650ffc2b9cec96c7ae06aad..75072ea439f3e1151e36148d9fa9e791d15cffb6 100644 --- a/eisgenerator/model.h +++ b/eisgenerator/model.h @@ -161,7 +161,7 @@ public: * * @return The uid. */ - size_t getUuid(); + size_t getUuid() const; /** * @brief Returns a vector of pointers to the circuit elements in this model. @@ -267,7 +267,7 @@ public: * * @return The function name in the code for this model. */ - std::string getCompiledFunctionName(); + std::string getCompiledFunctionName() const; /** * @brief Gets the function name in the code returned by getTorchScript and getCode for this model. diff --git a/model.cpp b/model.cpp index 21e0892d57d10ec0bc021add4842833bb0cf9270..4fdbc6881f147050b7bd27701d5f3aa2896657bc 100644 --- a/model.cpp +++ b/model.cpp @@ -565,7 +565,7 @@ std::vector<size_t> Model::getRecommendedParamIndices(eis::Range omegaRange, dou return indices; } -size_t Model::getUuid() +size_t Model::getUuid() const { return std::hash<std::string>{}(getModelStr()); } @@ -658,14 +658,14 @@ std::string Model::getTorchScript() std::stringstream out; out<<"def "<<getCompiledFunctionName()<<"(parameters: torch.Tensor, omegas: torch.Tensor) -> torch.Tensor:\n"; - out<<" assert parameters.size(0) is "<<parameters.size()<<"\n\n"; + out<<" assert parameters.size(0) == "<<parameters.size()<<"\n\n"; for(size_t i = 0; i < parameters.size(); ++i) out<<" "<<parameters[i]<<" = parameters["<<i<<"]\n"; out<<"\n return "<<formular<<"+0*omegas\n"; return out.str(); } -std::string Model::getCompiledFunctionName() +std::string Model::getCompiledFunctionName() const { return "model_"+std::to_string(getUuid()); }