Writes out a model to file in TorchScript format
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_model), | intent(in) | :: | model |
Model to write out |
||
| character(len=*), | intent(in) | :: | filename |
Filename for saved TorchScript model |
subroutine torch_model_save(model, filename) use, intrinsic :: iso_c_binding, only : c_null_char type(torch_model), intent(in) :: model !! Model to write out character(*), intent(in) :: filename !! Filename for saved TorchScript model interface subroutine torch_jit_save_c(model_c, filename_c) bind(c, name = 'torch_jit_save') use, intrinsic :: iso_c_binding, only : c_char, c_ptr implicit none type(c_ptr), value, intent(in) :: model_c character(c_char), intent(in) :: filename_c(*) end subroutine torch_jit_save_c end interface ! Need to append c_null_char at end of filename call torch_jit_save_c(model%p, trim(adjustl(filename))//c_null_char) end subroutine torch_model_save