Skip to content
Home » ValueError: get tensor value: stack_Concat__28 must be Const

ValueError: get tensor value: stack_Concat__28 must be Const

The below issues occurs while converting from tf2onnx or from onnx to tensorrt.

ValueError: get tensor value: stack_Concat__28 must be Const

raise ValueError("get tensor value: {} must be Const".format(self.name))
ValueError: get tensor value: stack_Concat__28 must be Const

Ways to be Helpful to solve this:

Reasons:

So this issue generally occurs when the image size or the Pooling value is not constant. Try changing them.

While TF ResizeBilinear can increase or reduce picture size, ONNX does not have an option to do both.
Upsample can only go up, whereas *Pool can only go down. We don’t know which op to map when the image or target size isn’t a constant.

Upsample (before opset9) and Pool only accept size as an attribute, which must be const, but TF ResizeBilinear supports size as an input.

It can also be solved if you run with --opset 10 while converting from tf2onnx. As you use –opset value above 10, these errors occur because they are no more constant value.

Also Read:

How to convert onnx model to tensorflow saved model