Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 #ifdef USE_INFERENCE 26 #ifdef USE_INFERENCE 27 # include "Par04InferenceMessenger.hh" << 27 #include "G4UIcmdWithADoubleAndUnit.hh" // for G4UIcmdWithADoubleAndUnit 28 << 28 #include "G4UIcmdWithAString.hh" // for G4UIcmdWithAString 29 # include "Par04InferenceSetup.hh" // for Pa << 29 #include "G4UIcmdWithAnInteger.hh" // for G4UIcmdWithAnInteger 30 << 30 #include "G4UIdirectory.hh" // for G4UIdirectory 31 # include "G4UIcmdWithADoubleAndUnit.hh" // << 31 #include "Par04InferenceMessenger.hh" 32 # include "G4UIcmdWithAString.hh" // for G4U << 32 #include "Par04InferenceSetup.hh" // for Par04InferenceSetup 33 # include "G4UIcmdWithAnInteger.hh" // for G << 33 #include <CLHEP/Units/SystemOfUnits.h> // for pi 34 # include "G4UIdirectory.hh" // for G4UIdire << 34 #include <G4ApplicationState.hh> // for G4State_Idle 35 << 35 #include <G4ThreeVector.hh> // for G4ThreeVector 36 # include <CLHEP/Units/SystemOfUnits.h> // f << 36 #include <G4UImessenger.hh> // for G4UImessenger 37 # include <G4ApplicationState.hh> // for G4S << 37 #include <string> // for stoi 38 # include <G4ThreeVector.hh> // for G4ThreeV << 39 # include <G4UImessenger.hh> // for G4UImess << 40 # include <string> // for stoi << 41 class G4UIcommand; 38 class G4UIcommand; 42 39 43 //....oooOO0OOooo........oooOO0OOooo........oo 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 41 45 Par04InferenceMessenger::Par04InferenceMesseng << 42 Par04InferenceMessenger::Par04InferenceMessenger( 46 : G4UImessenger(), fInference(aInference) << 43 Par04InferenceSetup *aInference) 47 { << 44 : G4UImessenger(), fInference(aInference) { 48 fExampleDir = new G4UIdirectory("/Par04/"); 45 fExampleDir = new G4UIdirectory("/Par04/"); 49 fExampleDir->SetGuidance("UI commands specif 46 fExampleDir->SetGuidance("UI commands specific to this example"); 50 47 51 fInferenceDir = new G4UIdirectory("/Par04/in 48 fInferenceDir = new G4UIdirectory("/Par04/inference/"); 52 fInferenceDir->SetGuidance("Inference constr 49 fInferenceDir->SetGuidance("Inference construction UI commands"); 53 50 54 fInferenceLibraryCmd = new G4UIcmdWithAStrin << 51 fInferenceLibraryCmd = >> 52 new G4UIcmdWithAString("/Par04/inference/setInferenceLibrary", this); 55 fInferenceLibraryCmd->SetGuidance("Inference 53 fInferenceLibraryCmd->SetGuidance("Inference library."); 56 fInferenceLibraryCmd->SetParameterName("Infe 54 fInferenceLibraryCmd->SetParameterName("InferenceLibrary", false); 57 fInferenceLibraryCmd->AvailableForStates(G4S 55 fInferenceLibraryCmd->AvailableForStates(G4State_Idle); 58 fInferenceLibraryCmd->SetToBeBroadcasted(tru 56 fInferenceLibraryCmd->SetToBeBroadcasted(true); 59 57 60 fSizeLatentVectorCmd = new G4UIcmdWithAnInte << 58 fSizeLatentVectorCmd = >> 59 new G4UIcmdWithAnInteger("/Par04/inference/setSizeLatentVector", this); 61 fSizeLatentVectorCmd->SetGuidance("Set size 60 fSizeLatentVectorCmd->SetGuidance("Set size of the latent space vector."); 62 fSizeLatentVectorCmd->SetParameterName("Size 61 fSizeLatentVectorCmd->SetParameterName("SizeLatentVector", false); 63 fSizeLatentVectorCmd->SetRange("SizeLatentVe 62 fSizeLatentVectorCmd->SetRange("SizeLatentVector>0"); 64 fSizeLatentVectorCmd->AvailableForStates(G4S 63 fSizeLatentVectorCmd->AvailableForStates(G4State_Idle); 65 fSizeLatentVectorCmd->SetToBeBroadcasted(tru 64 fSizeLatentVectorCmd->SetToBeBroadcasted(true); 66 65 67 fSizeConditionVectorCmd = 66 fSizeConditionVectorCmd = 68 new G4UIcmdWithAnInteger("/Par04/inference << 67 new G4UIcmdWithAnInteger("/Par04/inference/setSizeConditionVector", this); 69 fSizeConditionVectorCmd->SetGuidance("Set si 68 fSizeConditionVectorCmd->SetGuidance("Set size of the condition vector."); 70 fSizeConditionVectorCmd->SetParameterName("S 69 fSizeConditionVectorCmd->SetParameterName("SizeConditionVector", false); 71 fSizeConditionVectorCmd->SetRange("SizeCondi 70 fSizeConditionVectorCmd->SetRange("SizeConditionVector>0"); 72 fSizeConditionVectorCmd->AvailableForStates( 71 fSizeConditionVectorCmd->AvailableForStates(G4State_Idle); 73 fSizeConditionVectorCmd->SetToBeBroadcasted( 72 fSizeConditionVectorCmd->SetToBeBroadcasted(true); 74 73 75 fModelPathNameCmd = new G4UIcmdWithAString(" << 74 fModelPathNameCmd = >> 75 new G4UIcmdWithAString("/Par04/inference/setModelPathName", this); 76 fModelPathNameCmd->SetGuidance("Model path a 76 fModelPathNameCmd->SetGuidance("Model path and name."); 77 fModelPathNameCmd->SetParameterName("Name", 77 fModelPathNameCmd->SetParameterName("Name", false); 78 fModelPathNameCmd->AvailableForStates(G4Stat 78 fModelPathNameCmd->AvailableForStates(G4State_Idle); 79 fModelPathNameCmd->SetToBeBroadcasted(true); 79 fModelPathNameCmd->SetToBeBroadcasted(true); 80 80 81 fProfileFlagCmd = new G4UIcmdWithAnInteger(" << 81 fProfileFlagCmd = 82 fProfileFlagCmd->SetGuidance("Flag to save a << 82 new G4UIcmdWithAnInteger("/Par04/inference/setProfileFlag", this); >> 83 fProfileFlagCmd->SetGuidance( >> 84 "Flag to save a json file for model execution profiling."); 83 fProfileFlagCmd->SetParameterName("ProfileFl 85 fProfileFlagCmd->SetParameterName("ProfileFlag", false); 84 fProfileFlagCmd->SetRange("ProfileFlag>-1"); 86 fProfileFlagCmd->SetRange("ProfileFlag>-1"); 85 fProfileFlagCmd->AvailableForStates(G4State_ 87 fProfileFlagCmd->AvailableForStates(G4State_Idle); 86 fProfileFlagCmd->SetToBeBroadcasted(true); 88 fProfileFlagCmd->SetToBeBroadcasted(true); 87 89 88 fOptimizationFlagCmd = new G4UIcmdWithAnInte << 90 fOptimizationFlagCmd = >> 91 new G4UIcmdWithAnInteger("/Par04/inference/setOptimizationFlag", this); 89 fOptimizationFlagCmd->SetGuidance("Set optim 92 fOptimizationFlagCmd->SetGuidance("Set optimization flag"); 90 fOptimizationFlagCmd->SetParameterName("Opti 93 fOptimizationFlagCmd->SetParameterName("OptimizationFlag", false); 91 fOptimizationFlagCmd->SetRange("Optimization 94 fOptimizationFlagCmd->SetRange("OptimizationFlag>-1"); 92 fOptimizationFlagCmd->AvailableForStates(G4S 95 fOptimizationFlagCmd->AvailableForStates(G4State_Idle); 93 fOptimizationFlagCmd->SetToBeBroadcasted(tru 96 fOptimizationFlagCmd->SetToBeBroadcasted(true); 94 97 95 fMeshNbRhoCellsCmd = new G4UIcmdWithAnIntege << 98 fMeshNbRhoCellsCmd = 96 fMeshNbRhoCellsCmd->SetGuidance("Set number << 99 new G4UIcmdWithAnInteger("/Par04/inference/setNbOfRhoCells", this); >> 100 fMeshNbRhoCellsCmd->SetGuidance( >> 101 "Set number of rho cells in the cylindrical mesh readout."); 97 fMeshNbRhoCellsCmd->SetParameterName("NbRhoC 102 fMeshNbRhoCellsCmd->SetParameterName("NbRhoCells", false); 98 fMeshNbRhoCellsCmd->SetRange("NbRhoCells>0") 103 fMeshNbRhoCellsCmd->SetRange("NbRhoCells>0"); 99 fMeshNbRhoCellsCmd->AvailableForStates(G4Sta 104 fMeshNbRhoCellsCmd->AvailableForStates(G4State_Idle); 100 fMeshNbRhoCellsCmd->SetToBeBroadcasted(true) 105 fMeshNbRhoCellsCmd->SetToBeBroadcasted(true); 101 106 102 fMeshNbPhiCellsCmd = new G4UIcmdWithAnIntege << 107 fMeshNbPhiCellsCmd = 103 fMeshNbPhiCellsCmd->SetGuidance("Set number << 108 new G4UIcmdWithAnInteger("/Par04/inference/setNbOfPhiCells", this); >> 109 fMeshNbPhiCellsCmd->SetGuidance( >> 110 "Set number of phi cells in the cylindrical mesh readout."); 104 fMeshNbPhiCellsCmd->SetParameterName("NbPhiC 111 fMeshNbPhiCellsCmd->SetParameterName("NbPhiCells", false); 105 fMeshNbPhiCellsCmd->SetRange("NbPhiCells>0") 112 fMeshNbPhiCellsCmd->SetRange("NbPhiCells>0"); 106 fMeshNbPhiCellsCmd->AvailableForStates(G4Sta 113 fMeshNbPhiCellsCmd->AvailableForStates(G4State_Idle); 107 fMeshNbPhiCellsCmd->SetToBeBroadcasted(true) 114 fMeshNbPhiCellsCmd->SetToBeBroadcasted(true); 108 115 109 fMeshNbZCellsCmd = new G4UIcmdWithAnInteger( << 116 fMeshNbZCellsCmd = 110 fMeshNbZCellsCmd->SetGuidance("Set number of << 117 new G4UIcmdWithAnInteger("/Par04/inference/setNbOfZCells", this); >> 118 fMeshNbZCellsCmd->SetGuidance( >> 119 "Set number of z cells in the cylindrical mesh readout."); 111 fMeshNbZCellsCmd->SetParameterName("NbZCells 120 fMeshNbZCellsCmd->SetParameterName("NbZCells", false); 112 fMeshNbZCellsCmd->SetRange("NbZCells>0"); 121 fMeshNbZCellsCmd->SetRange("NbZCells>0"); 113 fMeshNbZCellsCmd->AvailableForStates(G4State 122 fMeshNbZCellsCmd->AvailableForStates(G4State_Idle); 114 fMeshNbZCellsCmd->SetToBeBroadcasted(true); 123 fMeshNbZCellsCmd->SetToBeBroadcasted(true); 115 124 116 fMeshSizeRhoCellsCmd = new G4UIcmdWithADoubl << 125 fMeshSizeRhoCellsCmd = 117 fMeshSizeRhoCellsCmd->SetGuidance("Set size << 126 new G4UIcmdWithADoubleAndUnit("/Par04/inference/setSizeOfRhoCells", this); >> 127 fMeshSizeRhoCellsCmd->SetGuidance( >> 128 "Set size of rho cells in the cylindrical readout mesh"); 118 fMeshSizeRhoCellsCmd->SetParameterName("Size 129 fMeshSizeRhoCellsCmd->SetParameterName("Size", false); 119 fMeshSizeRhoCellsCmd->SetRange("Size>0."); 130 fMeshSizeRhoCellsCmd->SetRange("Size>0."); 120 fMeshSizeRhoCellsCmd->SetUnitCategory("Lengt 131 fMeshSizeRhoCellsCmd->SetUnitCategory("Length"); 121 fMeshSizeRhoCellsCmd->AvailableForStates(G4S 132 fMeshSizeRhoCellsCmd->AvailableForStates(G4State_Idle); 122 fMeshSizeRhoCellsCmd->SetToBeBroadcasted(tru 133 fMeshSizeRhoCellsCmd->SetToBeBroadcasted(true); 123 134 124 fMeshSizeZCellsCmd = new G4UIcmdWithADoubleA << 135 fMeshSizeZCellsCmd = 125 fMeshSizeZCellsCmd->SetGuidance("Set size of << 136 new G4UIcmdWithADoubleAndUnit("/Par04/inference/setSizeOfZCells", this); >> 137 fMeshSizeZCellsCmd->SetGuidance( >> 138 "Set size of z cells in the cylindrical readout mesh"); 126 fMeshSizeZCellsCmd->SetParameterName("Size", 139 fMeshSizeZCellsCmd->SetParameterName("Size", false); 127 fMeshSizeZCellsCmd->SetRange("Size>0."); 140 fMeshSizeZCellsCmd->SetRange("Size>0."); 128 fMeshSizeZCellsCmd->SetUnitCategory("Length" 141 fMeshSizeZCellsCmd->SetUnitCategory("Length"); 129 fMeshSizeZCellsCmd->AvailableForStates(G4Sta 142 fMeshSizeZCellsCmd->AvailableForStates(G4State_Idle); 130 fMeshSizeZCellsCmd->SetToBeBroadcasted(true) 143 fMeshSizeZCellsCmd->SetToBeBroadcasted(true); 131 144 132 // Onnx Runtime Execution Provider flag comm 145 // Onnx Runtime Execution Provider flag commands 133 fCudaFlagCmd = new G4UIcmdWithAnInteger("/Pa 146 fCudaFlagCmd = new G4UIcmdWithAnInteger("/Par04/inference/setCudaFlag", this); 134 G4cout << "f CudaFlagCmd " << fCudaFlagCmd < 147 G4cout << "f CudaFlagCmd " << fCudaFlagCmd << G4endl; 135 fCudaFlagCmd->SetGuidance("Whether to use CU << 148 fCudaFlagCmd->SetGuidance( >> 149 "Whether to use CUDA Execution Provider for Onnx Runtime or not"); 136 fCudaFlagCmd->SetParameterName("CudaFlag", f 150 fCudaFlagCmd->SetParameterName("CudaFlag", false); 137 fCudaFlagCmd->SetRange("CudaFlag>-1"); 151 fCudaFlagCmd->SetRange("CudaFlag>-1"); 138 fCudaFlagCmd->AvailableForStates(G4State_Idl 152 fCudaFlagCmd->AvailableForStates(G4State_Idle); 139 fCudaFlagCmd->SetToBeBroadcasted(true); 153 fCudaFlagCmd->SetToBeBroadcasted(true); 140 154 141 /// OnnxRuntime Execution Provider Options 155 /// OnnxRuntime Execution Provider Options 142 /// Cuda 156 /// Cuda 143 fCudaOptionsDir = new G4UIdirectory("/Par04/ 157 fCudaOptionsDir = new G4UIdirectory("/Par04/inference/cuda/"); 144 fCudaOptionsDir->SetGuidance("Commands for s << 158 fCudaOptionsDir->SetGuidance( >> 159 "Commands for setting options for Cuda execution provider"); 145 160 146 fCudaDeviceIdCmd = new G4UIcmdWithAString("/ << 161 fCudaDeviceIdCmd = 147 fCudaDeviceIdCmd->SetGuidance("Device ID of << 162 new G4UIcmdWithAString("/Par04/inference/cuda/setDeviceId", this); >> 163 fCudaDeviceIdCmd->SetGuidance( >> 164 "Device ID of Device on which to run CUDA code"); 148 fCudaDeviceIdCmd->SetParameterName("CudaDevi 165 fCudaDeviceIdCmd->SetParameterName("CudaDeviceId", false); 149 fCudaDeviceIdCmd->AvailableForStates(G4State 166 fCudaDeviceIdCmd->AvailableForStates(G4State_Idle); 150 fCudaDeviceIdCmd->SetToBeBroadcasted(true); 167 fCudaDeviceIdCmd->SetToBeBroadcasted(true); 151 168 152 fCudaGpuMemLimitCmd = new G4UIcmdWithAString << 169 fCudaGpuMemLimitCmd = >> 170 new G4UIcmdWithAString("/Par04/inference/cuda/setGpuMemLimit", this); 153 fCudaGpuMemLimitCmd->SetGuidance("GPU Memory 171 fCudaGpuMemLimitCmd->SetGuidance("GPU Memory limit for CUDA"); 154 fCudaGpuMemLimitCmd->SetParameterName("CudaG 172 fCudaGpuMemLimitCmd->SetParameterName("CudaGpuMemLimit", false); 155 fCudaGpuMemLimitCmd->AvailableForStates(G4St 173 fCudaGpuMemLimitCmd->AvailableForStates(G4State_Idle); 156 fCudaGpuMemLimitCmd->SetToBeBroadcasted(true 174 fCudaGpuMemLimitCmd->SetToBeBroadcasted(true); 157 175 158 fCudaArenaExtendedStrategyCmd = << 176 fCudaArenaExtendedStrategyCmd = new G4UIcmdWithAString( 159 new G4UIcmdWithAString("/Par04/inference/c << 177 "/Par04/inference/cuda/setArenaExtendedStrategy", this); 160 fCudaArenaExtendedStrategyCmd->SetGuidance( 178 fCudaArenaExtendedStrategyCmd->SetGuidance( 161 "Strategy for extending the device memory << 179 "Strategy for extending the device memory arena for CUDA"); 162 fCudaArenaExtendedStrategyCmd->SetParameterN << 180 fCudaArenaExtendedStrategyCmd->SetParameterName("CudaArenaExtendedStrategy", >> 181 false); 163 fCudaArenaExtendedStrategyCmd->AvailableForS 182 fCudaArenaExtendedStrategyCmd->AvailableForStates(G4State_Idle); 164 fCudaArenaExtendedStrategyCmd->SetToBeBroadc 183 fCudaArenaExtendedStrategyCmd->SetToBeBroadcasted(true); 165 184 166 fCudaCudnnConvAlgoSearchCmd = << 185 fCudaCudnnConvAlgoSearchCmd = new G4UIcmdWithAString( 167 new G4UIcmdWithAString("/Par04/inference/c << 186 "/Par04/inference/cuda/setCudnnConvAlgoSearch", this); 168 fCudaCudnnConvAlgoSearchCmd->SetGuidance("Se << 187 fCudaCudnnConvAlgoSearchCmd->SetGuidance( 169 fCudaCudnnConvAlgoSearchCmd->SetParameterNam << 188 "Set which cuDNN Convolution Operation to use"); >> 189 fCudaCudnnConvAlgoSearchCmd->SetParameterName("CudaCudnnConvAlgoSearch", >> 190 false); 170 fCudaCudnnConvAlgoSearchCmd->AvailableForSta 191 fCudaCudnnConvAlgoSearchCmd->AvailableForStates(G4State_Idle); 171 fCudaCudnnConvAlgoSearchCmd->SetToBeBroadcas 192 fCudaCudnnConvAlgoSearchCmd->SetToBeBroadcasted(true); 172 193 173 fCudaDoCopyInDefaultStreamCmd = << 194 fCudaDoCopyInDefaultStreamCmd = new G4UIcmdWithAString( 174 new G4UIcmdWithAString("/Par04/inference/c << 195 "/Par04/inference/cuda/setDoCopyInDefaultStream", this); 175 fCudaDoCopyInDefaultStreamCmd->SetGuidance(" << 196 fCudaDoCopyInDefaultStreamCmd->SetGuidance( 176 fCudaDoCopyInDefaultStreamCmd->SetParameterN << 197 "Whether to use same stream for copying"); >> 198 fCudaDoCopyInDefaultStreamCmd->SetParameterName("CudaDoCopyInDefaultStream", >> 199 false); 177 fCudaDoCopyInDefaultStreamCmd->AvailableForS 200 fCudaDoCopyInDefaultStreamCmd->AvailableForStates(G4State_Idle); 178 fCudaDoCopyInDefaultStreamCmd->SetToBeBroadc 201 fCudaDoCopyInDefaultStreamCmd->SetToBeBroadcasted(true); 179 202 180 fCudaCudnnConvUseMaxWorkspaceCmd = << 203 fCudaCudnnConvUseMaxWorkspaceCmd = new G4UIcmdWithAString( 181 new G4UIcmdWithAString("/Par04/inference/c << 204 "/Par04/inference/cuda/setCudnnConvUseMaxWorkspace", this); 182 fCudaCudnnConvUseMaxWorkspaceCmd->SetGuidanc << 205 fCudaCudnnConvUseMaxWorkspaceCmd->SetGuidance( 183 fCudaCudnnConvUseMaxWorkspaceCmd->SetParamet << 206 "Memory Limit for cuDNN convolution operations"); >> 207 fCudaCudnnConvUseMaxWorkspaceCmd->SetParameterName( >> 208 "CudaCudnnConvUseMaxWorkspace", false); 184 fCudaCudnnConvUseMaxWorkspaceCmd->AvailableF 209 fCudaCudnnConvUseMaxWorkspaceCmd->AvailableForStates(G4State_Idle); 185 fCudaCudnnConvUseMaxWorkspaceCmd->SetToBeBro 210 fCudaCudnnConvUseMaxWorkspaceCmd->SetToBeBroadcasted(true); 186 } 211 } 187 212 188 //....oooOO0OOooo........oooOO0OOooo........oo 213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 189 214 190 Par04InferenceMessenger::~Par04InferenceMessen << 215 Par04InferenceMessenger::~Par04InferenceMessenger() { 191 { << 192 delete fInferenceLibraryCmd; 216 delete fInferenceLibraryCmd; 193 delete fSizeLatentVectorCmd; 217 delete fSizeLatentVectorCmd; 194 delete fSizeConditionVectorCmd; 218 delete fSizeConditionVectorCmd; 195 delete fModelPathNameCmd; 219 delete fModelPathNameCmd; 196 delete fProfileFlagCmd; 220 delete fProfileFlagCmd; 197 delete fOptimizationFlagCmd; 221 delete fOptimizationFlagCmd; 198 delete fMeshNbRhoCellsCmd; 222 delete fMeshNbRhoCellsCmd; 199 delete fMeshNbPhiCellsCmd; 223 delete fMeshNbPhiCellsCmd; 200 delete fMeshNbZCellsCmd; 224 delete fMeshNbZCellsCmd; 201 delete fMeshSizeRhoCellsCmd; 225 delete fMeshSizeRhoCellsCmd; 202 delete fMeshSizeZCellsCmd; 226 delete fMeshSizeZCellsCmd; 203 } 227 } 204 228 205 //....oooOO0OOooo........oooOO0OOooo........oo 229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 206 230 207 void Par04InferenceMessenger::SetNewValue(G4UI << 231 void Par04InferenceMessenger::SetNewValue(G4UIcommand *aCommand, 208 { << 232 G4String aNewValue) { 209 if (aCommand == fInferenceLibraryCmd) { 233 if (aCommand == fInferenceLibraryCmd) { 210 fInference->SetInferenceLibrary(aNewValue) 234 fInference->SetInferenceLibrary(aNewValue); 211 } 235 } 212 if (aCommand == fSizeLatentVectorCmd) { 236 if (aCommand == fSizeLatentVectorCmd) { 213 fInference->SetSizeLatentVector(std::stoi( 237 fInference->SetSizeLatentVector(std::stoi(aNewValue)); 214 } 238 } 215 if (aCommand == fSizeConditionVectorCmd) { 239 if (aCommand == fSizeConditionVectorCmd) { 216 fInference->SetSizeConditionVector(std::st 240 fInference->SetSizeConditionVector(std::stoi(aNewValue)); 217 } 241 } 218 if (aCommand == fModelPathNameCmd) { 242 if (aCommand == fModelPathNameCmd) { 219 fInference->SetModelPathName(aNewValue); 243 fInference->SetModelPathName(aNewValue); 220 } 244 } 221 if (aCommand == fProfileFlagCmd) { 245 if (aCommand == fProfileFlagCmd) { 222 fInference->SetProfileFlag(std::stoi(aNewV 246 fInference->SetProfileFlag(std::stoi(aNewValue)); 223 } 247 } 224 if (aCommand == fOptimizationFlagCmd) { 248 if (aCommand == fOptimizationFlagCmd) { 225 fInference->SetOptimizationFlag(std::stoi( 249 fInference->SetOptimizationFlag(std::stoi(aNewValue)); 226 } << 250 } else if (aCommand == fMeshNbRhoCellsCmd) { 227 else if (aCommand == fMeshNbRhoCellsCmd) { << 251 fInference->SetMeshNbOfCells(0, 228 fInference->SetMeshNbOfCells(0, fMeshNbRho << 252 fMeshNbRhoCellsCmd->GetNewIntValue(aNewValue)); 229 } << 253 } else if (aCommand == fMeshNbPhiCellsCmd) { 230 else if (aCommand == fMeshNbPhiCellsCmd) { << 254 fInference->SetMeshNbOfCells(1, 231 fInference->SetMeshNbOfCells(1, fMeshNbPhi << 255 fMeshNbPhiCellsCmd->GetNewIntValue(aNewValue)); 232 fInference->SetMeshSizeOfCells(1, << 256 fInference->SetMeshSizeOfCells( 233 2. * CLHEP: << 257 1, 2. * CLHEP::pi / fMeshNbPhiCellsCmd->GetNewIntValue(aNewValue)); 234 } << 258 } else if (aCommand == fMeshNbZCellsCmd) { 235 else if (aCommand == fMeshNbZCellsCmd) { << 259 fInference->SetMeshNbOfCells(2, 236 fInference->SetMeshNbOfCells(2, fMeshNbZCe << 260 fMeshNbZCellsCmd->GetNewIntValue(aNewValue)); 237 } << 261 } else if (aCommand == fMeshSizeRhoCellsCmd) { 238 else if (aCommand == fMeshSizeRhoCellsCmd) { << 262 fInference->SetMeshSizeOfCells( 239 fInference->SetMeshSizeOfCells(0, fMeshSiz << 263 0, fMeshSizeRhoCellsCmd->GetNewDoubleValue(aNewValue)); 240 } << 264 } else if (aCommand == fMeshSizeZCellsCmd) { 241 else if (aCommand == fMeshSizeZCellsCmd) { << 265 fInference->SetMeshSizeOfCells( 242 fInference->SetMeshSizeOfCells(2, fMeshSiz << 266 2, fMeshSizeZCellsCmd->GetNewDoubleValue(aNewValue)); 243 } 267 } 244 /// Onnx Runtime Execution Provider Flags 268 /// Onnx Runtime Execution Provider Flags 245 /// Cuda 269 /// Cuda 246 if (aCommand == fCudaFlagCmd) { 270 if (aCommand == fCudaFlagCmd) { 247 fInference->SetCudaFlag(std::stoi(aNewValu 271 fInference->SetCudaFlag(std::stoi(aNewValue)); 248 } 272 } 249 if (aCommand == fCudaDeviceIdCmd) { 273 if (aCommand == fCudaDeviceIdCmd) { 250 fInference->SetCudaDeviceId(aNewValue); 274 fInference->SetCudaDeviceId(aNewValue); 251 } << 275 } else if (aCommand == fCudaGpuMemLimitCmd) { 252 else if (aCommand == fCudaGpuMemLimitCmd) { << 253 fInference->SetCudaGpuMemLimit(aNewValue); 276 fInference->SetCudaGpuMemLimit(aNewValue); 254 } << 277 } else if (aCommand == fCudaArenaExtendedStrategyCmd) { 255 else if (aCommand == fCudaArenaExtendedStrat << 256 fInference->SetCudaArenaExtendedStrategy(a 278 fInference->SetCudaArenaExtendedStrategy(aNewValue); 257 } << 279 } else if (aCommand == fCudaCudnnConvAlgoSearchCmd) { 258 else if (aCommand == fCudaCudnnConvAlgoSearc << 259 fInference->SetCudaCudnnConvAlgoSearch(aNe 280 fInference->SetCudaCudnnConvAlgoSearch(aNewValue); 260 } << 281 } else if (aCommand == fCudaDoCopyInDefaultStreamCmd) { 261 else if (aCommand == fCudaDoCopyInDefaultStr << 262 fInference->SetCudaDoCopyInDefaultStream(a 282 fInference->SetCudaDoCopyInDefaultStream(aNewValue); 263 } << 283 } else if (aCommand == fCudaCudnnConvUseMaxWorkspaceCmd) { 264 else if (aCommand == fCudaCudnnConvUseMaxWor << 265 fInference->SetCudaCudnnConvUseMaxWorkspac 284 fInference->SetCudaCudnnConvUseMaxWorkspace(aNewValue); 266 } 285 } 267 } 286 } 268 287 269 //....oooOO0OOooo........oooOO0OOooo........oo 288 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 270 289 271 G4String Par04InferenceMessenger::GetCurrentVa << 290 G4String Par04InferenceMessenger::GetCurrentValue(G4UIcommand *aCommand) { 272 { << 273 G4String cv; 291 G4String cv; 274 292 275 if (aCommand == fInferenceLibraryCmd) { 293 if (aCommand == fInferenceLibraryCmd) { 276 cv = fInferenceLibraryCmd->ConvertToString << 294 cv = fInferenceLibraryCmd->ConvertToString( >> 295 fInference->GetInferenceLibrary()); 277 } 296 } 278 if (aCommand == fSizeLatentVectorCmd) { 297 if (aCommand == fSizeLatentVectorCmd) { 279 cv = fSizeLatentVectorCmd->ConvertToString << 298 cv = fSizeLatentVectorCmd->ConvertToString( >> 299 fInference->GetSizeLatentVector()); 280 } 300 } 281 if (aCommand == fSizeConditionVectorCmd) { 301 if (aCommand == fSizeConditionVectorCmd) { 282 cv = fSizeConditionVectorCmd->ConvertToStr << 302 cv = fSizeConditionVectorCmd->ConvertToString( >> 303 fInference->GetSizeConditionVector()); 283 } 304 } 284 if (aCommand == fModelPathNameCmd) { 305 if (aCommand == fModelPathNameCmd) { 285 cv = fModelPathNameCmd->ConvertToString(fI 306 cv = fModelPathNameCmd->ConvertToString(fInference->GetModelPathName()); 286 } 307 } 287 if (aCommand == fProfileFlagCmd) { 308 if (aCommand == fProfileFlagCmd) { 288 cv = fSizeLatentVectorCmd->ConvertToString 309 cv = fSizeLatentVectorCmd->ConvertToString(fInference->GetProfileFlag()); 289 } 310 } 290 if (aCommand == fOptimizationFlagCmd) { 311 if (aCommand == fOptimizationFlagCmd) { 291 cv = fSizeLatentVectorCmd->ConvertToString << 312 cv = fSizeLatentVectorCmd->ConvertToString( 292 } << 313 fInference->GetOptimizationFlag()); 293 else if (aCommand == fMeshNbRhoCellsCmd) { << 314 } else if (aCommand == fMeshNbRhoCellsCmd) { 294 cv = fMeshNbRhoCellsCmd->ConvertToString(f 315 cv = fMeshNbRhoCellsCmd->ConvertToString(fInference->GetMeshNbOfCells()[0]); 295 } << 316 } else if (aCommand == fMeshNbPhiCellsCmd) { 296 else if (aCommand == fMeshNbPhiCellsCmd) { << 297 cv = fMeshNbPhiCellsCmd->ConvertToString(f 317 cv = fMeshNbPhiCellsCmd->ConvertToString(fInference->GetMeshNbOfCells()[1]); 298 } << 318 } else if (aCommand == fMeshNbZCellsCmd) { 299 else if (aCommand == fMeshNbZCellsCmd) { << 300 cv = fMeshNbZCellsCmd->ConvertToString(fIn 319 cv = fMeshNbZCellsCmd->ConvertToString(fInference->GetMeshNbOfCells()[2]); 301 } << 320 } else if (aCommand == fMeshSizeRhoCellsCmd) { 302 else if (aCommand == fMeshSizeRhoCellsCmd) { << 321 cv = fMeshSizeRhoCellsCmd->ConvertToString( 303 cv = fMeshSizeRhoCellsCmd->ConvertToString << 322 fInference->GetMeshSizeOfCells()[0]); 304 } << 323 } else if (aCommand == fMeshSizeZCellsCmd) { 305 else if (aCommand == fMeshSizeZCellsCmd) { << 324 cv = fMeshSizeZCellsCmd->ConvertToString( 306 cv = fMeshSizeZCellsCmd->ConvertToString(f << 325 fInference->GetMeshSizeOfCells()[2]); 307 } 326 } 308 /// Onnx Runtime Execution Provider Flags 327 /// Onnx Runtime Execution Provider Flags 309 /// Cuda 328 /// Cuda 310 if (aCommand == fCudaDeviceIdCmd) { 329 if (aCommand == fCudaDeviceIdCmd) { 311 cv = fCudaDeviceIdCmd->ConvertToString(fIn 330 cv = fCudaDeviceIdCmd->ConvertToString(fInference->GetCudaDeviceId()); 312 } << 331 } else if (aCommand == fCudaGpuMemLimitCmd) { 313 else if (aCommand == fCudaGpuMemLimitCmd) { << 314 cv = fCudaGpuMemLimitCmd->ConvertToString( 332 cv = fCudaGpuMemLimitCmd->ConvertToString(fInference->GetCudaGpuMemLimit()); 315 } << 333 } else if (aCommand == fCudaArenaExtendedStrategyCmd) { 316 else if (aCommand == fCudaArenaExtendedStrat << 334 cv = fCudaArenaExtendedStrategyCmd->ConvertToString( 317 cv = fCudaArenaExtendedStrategyCmd->Conver << 335 fInference->GetCudaArenaExtendedStrategy()); 318 } << 336 } else if (aCommand == fCudaCudnnConvAlgoSearchCmd) { 319 else if (aCommand == fCudaCudnnConvAlgoSearc << 337 cv = fCudaCudnnConvAlgoSearchCmd->ConvertToString( 320 cv = fCudaCudnnConvAlgoSearchCmd->ConvertT << 338 fInference->GetCudaCudnnConvAlgoSearch()); 321 } << 339 } else if (aCommand == fCudaDoCopyInDefaultStreamCmd) { 322 else if (aCommand == fCudaDoCopyInDefaultStr << 340 cv = fCudaDoCopyInDefaultStreamCmd->ConvertToString( 323 cv = fCudaDoCopyInDefaultStreamCmd->Conver << 341 fInference->GetCudaDoCopyInDefaultStream()); 324 } << 342 } else if (aCommand == fCudaCudnnConvUseMaxWorkspaceCmd) { 325 else if (aCommand == fCudaCudnnConvUseMaxWor << 326 cv = fCudaCudnnConvUseMaxWorkspaceCmd->Con 343 cv = fCudaCudnnConvUseMaxWorkspaceCmd->ConvertToString( 327 fInference->GetCudaCudnnConvUseMaxWorksp << 344 fInference->GetCudaCudnnConvUseMaxWorkspace()); 328 } 345 } 329 346 330 return cv; 347 return cv; 331 } 348 } 332 349 333 #endif 350 #endif 334 351