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

Operator overloads not working correctly for non-integer scalars #224

Closed
jwallwork23 opened this issue Jan 7, 2025 · 0 comments · Fixed by #225
Closed

Operator overloads not working correctly for non-integer scalars #224

jwallwork23 opened this issue Jan 7, 2025 · 0 comments · Fixed by #225
Assignees
Labels
autograd Tasks towards the online training / automatic differentiation feature bug Something isn't working

Comments

@jwallwork23
Copy link
Contributor

Unfortunately, there's an oversight in my implementation of the operator overloads that involve scalars. They only seem to currently work for integer scalars (only integer scalars are considered in the autograd demo).

For example, changing the divisor with

diff --git a/examples/6_Autograd/autograd.f90 b/examples/6_Autograd/autograd.f90
index cf60494..9d73853 100644
--- a/examples/6_Autograd/autograd.f90
+++ b/examples/6_Autograd/autograd.f90
@@ -52,7 +52,7 @@ program example
   ! Check arithmetic operations work for torch_tensors
   write (*,*) "a = ", in_data1(:,1)
   write (*,*) "b = ", in_data2(:,1)
-  Q = 3 * (a**3 - b * b / 3)
+  Q = 3 * (a**3 - b * b / 3.0)
 
   ! Extract a Fortran array from a Torch tensor
   call torch_tensor_to_array(Q, out_data, shape(in_data1))

on the main branch results in the test failure:

test 2
    Start 2: fautograd

2: Test command: /home/joe/software/FTorch/src/build/test/examples/6_Autograd/autograd
2: Test timeout computed to be: 1500
2:  a =    2.00000000       3.00000000    
2:  b =    6.00000000       4.00000000    
2:  Q = 3 * (a ** 3 - b * b / 2) =   24.0000000       81.0000000    
2: FAILED :: [torch_tensor_to_array] relative tolerance =  0.1000E-04
2:  Error :: out_data does not match expected value
2: STOP 999
2/2 Test #2: fautograd ........................***Failed  Required regular expression not found. Regex=[Autograd example ran successfully
]  0.23 sec
@jwallwork23 jwallwork23 added bug Something isn't working autograd Tasks towards the online training / automatic differentiation feature labels Jan 7, 2025
@jwallwork23 jwallwork23 self-assigned this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autograd Tasks towards the online training / automatic differentiation feature bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant