Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWE fortran python #33

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

MWE fortran python #33

wants to merge 6 commits into from

Conversation

TomMelt
Copy link
Collaborator

@TomMelt TomMelt commented Dec 18, 2024

This PR adds minimum worked examples of inference in python and fortran

  • add README.md
  • add python example
  • add fortran example

closes #11
closes #25

@@ -16,7 +13,7 @@ def Inference_and_Save_ANN_CNN(model, testset, testloader, bs_test, device, sten
nx = len(lon)

model.eval()
model.dropout.train() # this enables dropout during inference. By default dropout is OFF when model.eval()=True
# model.dropout.train() # this enables dropout during inference. By default dropout is OFF when model.eval()=True
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amangupta2 , is this ok to disable? or do we need it for inference

call torch_model_load(model, "saved_nlgw_model_gpu.pt", device_type=torch_kCUDA, device_index=0)

! Infer
! do i = 1, 100
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this loop can be removed

@amangupta2 amangupta2 mentioned this pull request Jan 23, 2025
@TomMelt TomMelt force-pushed the mwe-fortran-python branch from 4bc755a to 7d91f97 Compare February 5, 2025 15:06
@TomMelt TomMelt changed the base branch from main to refactor_ann_and_unet February 5, 2025 15:07
Base automatically changed from refactor_ann_and_unet to main February 5, 2025 16:34
@TomMelt TomMelt force-pushed the mwe-fortran-python branch from a5cecba to c389d75 Compare February 5, 2025 16:38
Comment on lines +74 to +78
# if self.fac == 1:
# x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
# elif self.fac == 2:
# x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
# x = torch.squeeze(self.dropout0_2(self.act_cnn2(self.conv2(x))))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should find a proper solution to this for torchscripting

@@ -189,6 +192,22 @@ def Inference_and_Save_ANN_CNN(model, testset, testloader, bs_test, device, sten
OUT = OUT.reshape(T[0] * T[1], -1)
PRED = model(INP)

print("saving data...")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this part optional via command line args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trace pytorch NN to pt file Create MWE Fortran to run inference
1 participant