How do I filter out memberships (by relationship)?
You can use 'Membership Owner ID' filter under filters tab of report. 

When you set 'Membership Owner ID' as 'is empty(NULL)' it will show all the primary membership owners that is membership not created by relationship


When you set 'Membership Owner ID' as 'is not empty(NULL)' it will show all the secondary membership owners that is membership created by relationship membership


PS: Don't miss to filter Membership type ;)

HTH

Pradeep