Skip to content

Commit c68f188

Browse files
committed
skip rank query if known
1 parent 83afc1e commit c68f188

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/ops/math.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ for reduction in [:sum, :prod, :min, :max, :all, :any, :mean]
180180
name = $(capitalize(reduction))
181181
end
182182

183-
if axis == nothing
183+
shape = get_shape(n)
184+
if axis == nothing && shape.rank_unknown
184185
n = Tensor(n) # TODO: rewrite this
185186
desc_rank = tf.with_op_name(nothing, "Rank") do
186187
NodeDescription("Rank")
@@ -204,6 +205,9 @@ for reduction in [:sum, :prod, :min, :max, :all, :any, :mean]
204205
end
205206
else
206207
desc = tf.with_op_name(nothing, name) do
208+
if axis == nothing
209+
axis = 1:length(shape.dims)
210+
end
207211
@tf reduction_indices = constant(Int32.(axis.-1))
208212
desc = NodeDescription($(capitalize(reduction)))
209213
add_input(desc, Tensor(n))

0 commit comments

Comments
 (0)