Preheat the oven to 400°F (204°C).
Butter a 9x13-inch baking dish.
In a small pot, heat cream and garlic just until it simmers.
Arrange a layer of sweet potato slices at the bottom.
Sprinkle with salt, pepper, and thyme.
Add a layer of Gruyère cheese.
Repeat the layers until all ingredients are used, ending with cheese.
Pour the warm cream over the potatoes.
Cover with foil and bake for 30 minutes.
Remove foil and bake for another 15-20 minutes until potatoes are tender and cheese is golden brown.
Let it cool for 5 minutes before serving.