Device-specific : Added missing includes in template_base (it was miraculously compiling until now). Added one more check in matrix_product_template.