Add backend check to primitives

This is based on #779.