Analog optical computer for AI inference and combinatorial optimization