In this work, we report the bidirectional photoresponse of the carbon-based graphdiyne/graphene (GDY/Gr) heterojunction photodetector toward the optical logic gates. The uniform GDY film was facilely grown on the surface of Gr serving as the template. Under mV-level bias, the resultant Au/GDY/Gr/Au devices manifest the bidirectional photoresponse to a broad wavelength range with rapid response time, namely, positive and negative photoresponse under negative and positive bias, respectively. It can be understood from the viewpoint of the divergence and coincidence between in-plane and external potential. Furthermore, the optically operated logical gates including logic AND, OR, and Exclusive-OR gates have been realized by integrating the fabricated Au/GDY/Gr/Au devices, converting optical signals to electrical signals in real-time. It suggests the potential application of GDY/Gr heterojunction toward visible-NIR detector as well as the stable optical logic units.