diff --git a/loopy/library/reduction.py b/loopy/library/reduction.py index bd085b7e87f521b0a7daaeaefb0f16e60de26701..3c5f4a142b04eb22773a044cd87055e89313b892 100644 --- a/loopy/library/reduction.py +++ b/loopy/library/reduction.py @@ -123,7 +123,8 @@ class ScalarReductionOperation(ReductionOperation): class SumReductionOperation(ScalarReductionOperation): def neutral_element(self, dtype): - return dtype.numpy_dtype.type(0) + # FIXME: Document that we always use an int here. + return 0 def __call__(self, dtype, operand1, operand2): return operand1 + operand2 @@ -131,7 +132,8 @@ class SumReductionOperation(ScalarReductionOperation): class ProductReductionOperation(ScalarReductionOperation): def neutral_element(self, dtype): - return dtype.numpy_dtype.type(1) + # FIXME: Document that we always use an int here. + return 1 def __call__(self, dtype, operand1, operand2): return operand1 * operand2 diff --git a/loopy/target/c/__init__.py b/loopy/target/c/__init__.py index ed1ba1ce9147cd7d2244031c5099a840d375ad29..e9457233f854fb47ec169cf69d988ab7aba4d6b4 100644 --- a/loopy/target/c/__init__.py +++ b/loopy/target/c/__init__.py @@ -651,18 +651,11 @@ class CASTBuilder(ASTBuilderBase): def emit_tuple_assignment(self, codegen_state, insn): ecm = codegen_state.expression_to_code_mapper - parameters = insn.expression.parameters - parameter_dtypes = tuple(ecm.infer_type(par) for par in parameters) - from cgen import Assign, block_if_necessary assignments = [] - for i, (assignee, tgt_dtype) in enumerate( - zip(insn.assignees, parameter_dtypes)): - if tgt_dtype != ecm.infer_type(assignee): - raise LoopyError("type mismatch in %d'th (0-based) left-hand " - "side of instruction '%s'" % (i, insn.id)) - + for i, (assignee, parameter) in enumerate( + zip(insn.assignees, insn.expression.parameters)): lhs_code = ecm(assignee, prec=PREC_NONE, type_context=None) assignee_var_name = insn.assignee_var_names()[i] lhs_var = codegen_state.kernel.get_var_descriptor(assignee_var_name) @@ -671,8 +664,8 @@ class CASTBuilder(ASTBuilderBase): from loopy.expression import dtype_to_type_context rhs_type_context = dtype_to_type_context( codegen_state.kernel.target, lhs_dtype) - rhs_code = ecm(parameters[i], prec=PREC_NONE, - type_context=rhs_type_context, needed_dtype=lhs_dtype) + rhs_code = ecm(parameter, prec=PREC_NONE, + type_context=rhs_type_context, needed_dtype=lhs_dtype) assignments.append(Assign(lhs_code, rhs_code)) diff --git a/test/test_scan.py b/test/test_scan.py index c225c2c1c3670edbbebd3d389f368b2085e23190..08754819c9a156403aba689cb3e9c238144e7905 100644 --- a/test/test_scan.py +++ b/test/test_scan.py @@ -182,7 +182,6 @@ def test_nested_scan(ctx_factory, i_tag, j_tag): knl = lp.fix_parameters(knl, n=10) knl = lp.tag_inames(knl, dict(i=i_tag, j=j_tag)) - knl = lp.add_dtypes(knl, dict(tmp=int)) knl = lp.realize_reduction(knl, force_scan=True) print(knl)