Bake sweet potatoes until very soft. Let cool slightly and remove and discard skin. Mash pulp with a fork and measure out 5 cups. Place in a mixing bowl.
While sweet potatoes are baking, cook bacon in a nonstick skillet. Remove bacon, crumble, and set aside.
Pour off all but 1 1/2 tablespoons bacon grease.
Cook onion in bacon grease until soft, about 10 minutes. Just before removing from heat, add rosemary and thyme.
To mixing bowl with sweet potatoes add 2 tablespoons butter, cream, egg, salt, pepper, and cayenne. Beat until smooth.
Stir in onion mixture, 3/4 cup shredded Gruyere cheese, and half the crumbled bacon.
Transfer mixture to a lightly greased casserole dish.
Toss together melted butter, Panko crumbs and pecans.
Top casserole with remaining gruyere and Panko crumb mixture. Bake at 350 degrees for 30 minutes. Broil just long enough to brown the Panko crumbs.