No better way to do it at this moment....   We want to say this CSE pass can only be applied on certain dialect... where the ops in this dialect are functional (non-stateful)...     You will be able to do this when we have define the "Canonical/Functional Aten Opset". 