Repository: pytorch/glow

Issue #3827: [Reshape] Allow the shape to be computed from constants
Created: 2019-11-28T12:45:42Z
Assume we have the following case:

Assume also that even though the graph has this form, all the tensor sizes are statically known (that is the size for the output of conv and transpose are known). Right now this model will not work because the Reshape node complains that the "shape" operator is not explicitly a constant even though conceptually the shape is a constant.
Can we do something to support this case?
Maybe something like moving the restriction of "shape" operand being a constant right after all the graph optimizations took place.

Duplicate issue #3932: model-compiler fails with 'Error message: could not find constant with name 34'
Created: 2019-12-20T08:48:24Z
Just recently I have built and installed glow. I was trying out model-compiler utility with CPU backend to compile an onnx model exported by torch.onnx.export with export_params=True, opset_version=10, do_constant_folding=True parameters. I get the following errors:
WARNING: Logging before InitGoogleLogging() is written to STDERR
F1220 08:26:53.513170  2989 Error.cpp:119] exitOnError(Error) got an unexpected ErrorValue: 
Error message: could not find constant with name 344
Error return stack:
../lib/Importer/ProtobufLoader.cpp:89
../lib/Importer/ONNXModelLoader.cpp:1187
../lib/Importer/ONNXModelLoader.cpp:2288
../lib/Importer/ONNXModelLoader.cpp:2380
../lib/Importer/ONNXModelLoader.cpp:2394
*** Check failure stack trace: ***
../../../bin/model-compiler[0x718dbf]
../../../bin/model-compiler[0x7171e2]
../../../bin/model-compiler[0x7191c8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7f83effa8890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f83ef073e97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f83ef075801]
/usr/lib/x86_64-linux-gnu/libglog.so.0(+0xa1f9)[0x7f83ef9d11f9]
/usr/lib/x86_64-linux-gnu/libglog.so.0(+0xc0cd)[0x7f83ef9d30cd]
/usr/lib/x86_64-linux-gnu/libglog.so.0(_ZN6google10LogMessage9SendToLogEv+0x283)[0x7f83ef9d4f33]
/usr/lib/x86_64-linux-gnu/libglog.so.0(_ZN6google10LogMessage5FlushEv+0xb8)[0x7f83ef9d2c28]
/usr/lib/x86_64-linux-gnu/libglog.so.0(_ZN6google15LogMessageFatalD2Ev+0x9)[0x7f83ef9d5999]
../../../bin/model-compiler[0x257318c]
../../../bin/model-compiler[0x6665cf]
../../../bin/model-compiler[0x4b7126]
../../../bin/model-compiler[0x4bec81]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f83ef056b97]
../../../bin/model-compiler[0x4b594a]
Aborted (core dumped)

Is this error related to opset version I am using? What version of Opset can I specify in pytorch to make compatible with Glow? I am using Pytorch 1.4 (nightly) version. I tried exporting for opset 7 but pytorch is throwing this error: RuntimeError: ONNX export failed on arange, which is not implemented for opset 7. Try exporting with other opset versions

Closing comment (2019-12-24T10:58:27Z): The problem is that Glow can only use static sizes (that is tensor sizes which are constant at compile time). In particular, for the node ConstantOfShape which generates a constant at run-time based on a given size (the input), Glow requires the input to be a constant and not to be dynamically generated at run-time (that is to be the output of another node).
This problem is related to #3827.
One way would be to modify the model such that no tensor size is dynamically computed although it would be interesting for Glow to figure that out automatically,