Walmrt’s growing investment in AI is also aimed at closing the gap with online behemoth Amazon.