How to compare two symbols



I am trying to compare two sumbols using the “__eq(other)” function ( so here is an example for x and y symbols:

if x.__eq__(y):

I am getting a runtime error wirh message:

NotImplementedForSymbol: Function __bool__ (namely operator "bool") is not implemented for Symbol and only available in NDArray.

Any one has an idea of how to do this comparison the right way?


Your if statement is not correct, because __eq__will return a Symbol and if cannot evaluate that. The following will work:

if x.__eq__(y).__bool__: