Skip to content

Commit ea74c87

Browse files
committed
single shape macro
1 parent 66e662c commit ea74c87

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

include/common.fypp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,6 @@ ${prefix + joinstr.join([line.strip() for line in txt.split("\n")]) + suffix}$
230230
#:endif
231231
#:enddef
232232

233-
#! Brace enclosed, comma separated Fortran expressions for a shape.
234-
#!
235-
#! It defines an output variable with the same shape as the input variable.
236-
#!
237-
#! Args:
238-
#! varname (str): Name of the variable to be used as origin
239-
#! origrank (int): Rank of the original variable
240-
#!
241-
#! Returns:
242-
#! Shape expression enclosed in braces, so that it can be used as suffix to
243-
#! define array shapes in declarations.
244-
#!
245-
#:def shape(varname, origrank)
246-
#:assert origrank > 0
247-
#:if origrank > 1
248-
#:call join_lines(joinstr=", ", prefix="(", suffix=")")
249-
#:for i in range(1, origrank+1)
250-
size(${varname}$, ${i}$)
251-
#:endfor
252-
#:endcall
253-
#:endif
254-
#:enddef
255-
256233

257234
#! Generates a routine name from a generic name, rank, type and kind
258235
#!

src/stdlib_specialfunctions.fypp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ module stdlib_specialfunctions
355355
#:for rank in RANKS
356356
pure module function softmax_r${rank}$_${rk}$( x , dim ) result( y )
357357
${rt}$, intent(in) :: x${ranksuffix(rank)}$
358-
${rt}$ :: y${shape('x', rank)}$
358+
${rt}$ :: y${shape_from_array_size('x', rank)}$
359359
integer, intent(in), optional :: dim
360360
end function
361361
#:endfor
@@ -377,7 +377,7 @@ module stdlib_specialfunctions
377377
#:for rank in RANKS
378378
pure module function softmax_grad_r${rank}$_${rk}$( x , dim ) result( y )
379379
${rt}$, intent(in) :: x${ranksuffix(rank)}$
380-
${rt}$ :: y${shape('x', rank)}$
380+
${rt}$ :: y${shape_from_array_size('x', rank)}$
381381
integer, intent(in), optional :: dim
382382
end function
383383
#:endfor
@@ -399,7 +399,7 @@ module stdlib_specialfunctions
399399
#:for rank in RANKS
400400
pure module function logsoftmax_r${rank}$_${rk}$( x , dim ) result( y )
401401
${rt}$, intent(in) :: x${ranksuffix(rank)}$
402-
${rt}$ :: y${shape('x', rank)}$
402+
${rt}$ :: y${shape_from_array_size('x', rank)}$
403403
integer, intent(in), optional :: dim
404404
end function
405405
#:endfor

src/stdlib_specialfunctions_activations.fypp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ end function
232232
#:for rank in RANKS
233233
pure module function softmax_r${rank}$_${rk}$( x , dim ) result( y )
234234
${rt}$, intent(in) :: x${ranksuffix(rank)}$
235-
${rt}$ :: y${shape('x', rank)}$
235+
${rt}$ :: y${shape_from_array_size('x', rank)}$
236236

237237
integer, intent(in), optional :: dim
238238
integer :: dim_, j
@@ -271,7 +271,7 @@ end function
271271
#:for rank in RANKS
272272
pure module function softmax_grad_r${rank}$_${rk}$( x , dim ) result( y )
273273
${rt}$, intent(in) :: x${ranksuffix(rank)}$
274-
${rt}$ :: y${shape('x', rank)}$
274+
${rt}$ :: y${shape_from_array_size('x', rank)}$
275275

276276
integer, intent(in), optional :: dim
277277
integer :: dim_
@@ -300,7 +300,7 @@ end function
300300
#:for rank in RANKS
301301
pure module function logsoftmax_r${rank}$_${rk}$( x , dim ) result( y )
302302
${rt}$, intent(in) :: x${ranksuffix(rank)}$
303-
${rt}$ :: y${shape('x', rank)}$
303+
${rt}$ :: y${shape_from_array_size('x', rank)}$
304304

305305
integer, intent(in), optional :: dim
306306
integer :: dim_, j

0 commit comments

Comments
 (0)