Magnetic tunneling junctions (MTJs) lie in the core of magnetic random access memory, holding promise in integrating memory and computing to reduce hardware complexity, transition latency, and power consumption. However, traditional MTJs are insensitive to light, limiting their functionality in in-memory sensing─a crucial component for machine vision systems in artificial intelligence applications. Herein, the convergence of magnetic memory with optical sensing capabilities is achieved in the all-two-dimensional (2D) magnetic junction Fe