From 8314a36073e746366e2f7fd128ae707e59d262b5 Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Tue, 26 Mar 2024 15:36:56 -0700 Subject: [PATCH] Update hamming_distance test to use rotate-and-reduce Depends on https://github.com/google/heir/pull/531 Fixes https://github.com/google/heir/issues/521 PiperOrigin-RevId: 619333026 --- tests/simd/hamming_distance.mlir | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/simd/hamming_distance.mlir b/tests/simd/hamming_distance.mlir index f8aa39500..81ce90f34 100644 --- a/tests/simd/hamming_distance.mlir +++ b/tests/simd/hamming_distance.mlir @@ -1,22 +1,14 @@ // RUN: heir-opt --secretize=entry-function=hamming --wrap-generic --canonicalize --cse \ -// RUN: --full-loop-unroll --cse --canonicalize --insert-rotate --cse --canonicalize \ +// RUN: --full-loop-unroll --cse --canonicalize --insert-rotate --cse --canonicalize --rotate-and-reduce --cse --canonicalize \ // RUN: %s | FileCheck %s // CHECK-LABEL: @hamming // CHECK: secret.generic // CHECK: arith.subi // CHECK-NEXT: arith.muli -// CHECK-NEXT: tensor_ext.rotate -// CHECK-NEXT: arith.addi -// CHECK-NEXT: tensor_ext.rotate -// CHECK-NEXT: arith.addi -// CHECK-NEXT: tensor_ext.rotate -// CHECK-NEXT: arith.addi -// CHECK-NEXT: tensor.extract -// CHECK-NEXT: secret.yield - -// TODO(#521): support rotate-and-reduce when the input is already a series of incremental rotations, -// as this IR is currently lowered to 4-1 rotate operations to sum after doing (x-y)**2 in SIMD. +// CHECK-COUNT-2: tensor_ext.rotate +// CHECK-NOT: tensor_ext.rotate +// CHECK: secret.yield func.func @hamming(%arg0: tensor<4xi16> {secret.secret}, %arg1: tensor<4xi16> {secret.secret}) -> i16 { %c0 = arith.constant 0 : index