Undocumented optimisation passes?

In a custom Conv2D op I am writing, I’ve found that for OpenCL code generation for full networks fails when I run with an optimisation level greater than -o0.

  Did you forget to bind?
    Variable `placeholder` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.
    Variable `placeholder` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.
    Variable `T_relu` is directly accessed by host memory (it is not contained in a thread environment or in the function arguments.

I’ve discussed this sort of thing in other threads and I think I know how to deal with this kind of error when it appears at -O0 (namely, ensure GPU threads are bound properly). My initial thought for this case is that would be ReLU fusion not binding in my Conv2D op properly.

Looking at the available passes in build_config (see docs), we have these passes available:

OPT_PASS_LEVEL = {
    "SimplifyInference": 0,
    "OpFusion": 1,
    "FoldConstant": 2,
    "FoldScaleAxis": 3,
    "AlterOpLayout": 3,
    "CanonicalizeOps": 3,
    "CanonicalizeCast": 3,
    "EliminateCommonSubexpr": 3,
    "CombineParallelConv2D": 4,
    "CombineParallelDense": 4,
    "CombineParallelBatchMatmul": 4,
    "FastMath": 4
}

To debug, I’ve set opt_level to 0, and set the build_config arguments required_pass and disabled_pass.

I found that all passes are fine (including OpFusion), except for "FoldConstant", which causes code generation to fail with the error:

TVMError: found add; operators should be removed by future passes; try fusing and lowerin.

This is where the strangeness begins. With disabled_pass=["FoldConstant"], and required_pass set to all other passes in the above list, I raise the optimisation level to 1, 2, or 3. And the error is the same as above (Did you forget to bind?).

Are there optimisation passes that are not listed in the docs that are being activated by raising the level?

3 Likes