Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

foreach operator does not support input's dimension unknown #12470

@roywei

Description

@roywei

Description

In mxnet symbol, None shape is not supported, however we can use 0 as placeholder dimensions.
See: #7981
we can use

x = mx.sym.var('x', shape=(0, 100))

instead of

x = mx.sym.var('x', shape=(None, 100))

But foreach operator will throw error due to check here:
https://github.com/apache/incubator-mxnet/blob/master/src/operator/control_flow.cc#L317

Error Message:

mxnet.base.MXNetError: Error in operator _foreach4: [11:26:26] src/operator/control_flow.cc:317: Check failed: len > 0 (0 vs. 0) 
Stack trace returned 8 entries:
[bt] (0) 0   libmxnet.so                         0x0000000102854640 libmxnet.so + 26176
[bt] (1) 1   libmxnet.so                         0x00000001028543ef libmxnet.so + 25583
[bt] (2) 2   libmxnet.so                         0x0000000103f61e3f MXTVMBridge + 111375
[bt] (3) 3   libmxnet.so                         0x0000000103dda022 MXNDListFree + 333138
[bt] (4) 4   libmxnet.so                         0x0000000103dd240f MXNDListFree + 301375
[bt] (5) 5   libmxnet.so                         0x0000000103d74a65 MXSymbolInferShape + 2373
[bt] (6) 6   libmxnet.so                         0x0000000103d77100 MXSymbolInferShapePartial + 112
[bt] (7) 7   libffi.6.dylib                      0x0000000101fc3884 ffi_call_unix64 + 76

Minimum reproducible example

step = lambda data, states: (data + states[0], [states[0] * 2])
data = mx.sym.var('data', shape=(0,100))
states = [mx.sym.var('state')]
outs, states = mx.sym.contrib.foreach(step, data, states)
outs.infer_shape_partial()

What have you tried to solve it?

removing line 317 works, will open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions