Skip to content

Commit ef302d9

Browse files
committed
Add boilerplate ftorch_optim.F90 module and C++ ready for optimisers.
1 parent 3e78599 commit ef302d9

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ find_package(Torch REQUIRED)
8080

8181
# Library with C and Fortran bindings
8282
add_library(${LIB_NAME} SHARED src/ctorch.cpp src/ftorch.F90
83+
src/ftorch_optim.F90
8384
src/ftorch_test_utils.f90)
8485

8586
# Define compile definitions, including GPU devices
@@ -129,6 +130,8 @@ install(
129130
# Install Fortran module files
130131
install(FILES "${CMAKE_BINARY_DIR}/modules/ftorch.mod"
131132
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIB_NAME}")
133+
install(FILES "${CMAKE_BINARY_DIR}/modules/ftorch_optim.mod"
134+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIB_NAME}")
132135
install(FILES "${CMAKE_BINARY_DIR}/modules/ftorch_test_utils.mod"
133136
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIB_NAME}")
134137

src/ctorch.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ void torch_tensor_power_float(torch_tensor_t output, const torch_tensor_t tensor
379379
*out = pow(*t, *exp);
380380
}
381381

382+
// =============================================================================
383+
// --- Torch optimisers API
384+
// =============================================================================
385+
386+
387+
382388
// =============================================================================
383389
// --- Torch model API
384390
// =============================================================================

src/ctorch.h

+5
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ EXPORT_C void torch_tensor_power_float(torch_tensor_t output,
247247
const torch_tensor_t tensor,
248248
const torch_float_t exponent);
249249

250+
// =============================================================================
251+
// --- Torch optimisers API
252+
// =============================================================================
253+
254+
250255
// =============================================================================
251256
// --- Torch model API
252257
// =============================================================================

src/ftorch_optim.F90

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
!| Optimisers module for FTorch.
2+
!
3+
! * License
4+
! FTorch is released under an MIT license.
5+
! See the [LICENSE](https://github.com/Cambridge-ICCS/FTorch/blob/main/LICENSE)
6+
! file for details.
7+
8+
module ftorch_optim
9+
10+
use, intrinsic :: iso_c_binding, only: c_associated, c_null_ptr, c_ptr
11+
use, intrinsic :: iso_fortran_env, only: int32
12+
13+
use ftorch, only: ftorch_int
14+
15+
implicit none
16+
17+
public
18+
19+
! ============================================================================
20+
! ---
21+
! ============================================================================
22+
23+
24+
end module ftorch_optim

0 commit comments

Comments
 (0)