From: Francis Russell Date: Fri, 8 Jun 2012 10:28:31 +0000 (+0100) Subject: Fix off-by-one errors in inner product generated code. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=refs%2Fheads%2Fstable;p=francis%2Fofc.git Fix off-by-one errors in inner product generated code. --- diff --git a/src/ofc/generators/onetep/InnerProduct.scala b/src/ofc/generators/onetep/InnerProduct.scala index 9d7143b..92c6dab 100644 --- a/src/ofc/generators/onetep/InnerProduct.scala +++ b/src/ofc/generators/onetep/InnerProduct.scala @@ -22,7 +22,7 @@ class InnerProduct(left: Field, right: Field) extends Scalar { for (dim <- 0 to 2) yield new Max[IntType](leftOrigin(dim), rightOrigin(dim)) val bottomRight : Seq[Expression[IntType]] = - for (dim <- 0 to 2) yield new Min[IntType](leftOrigin(dim) + leftSize(dim), rightOrigin(dim) + rightSize(dim)) + for (dim <- 0 to 2) yield new Min[IntType](leftOrigin(dim) + leftSize(dim), rightOrigin(dim) + rightSize(dim)) - 1 val indices = for(dim <- 0 to 2) yield { val index = new DeclaredVarSymbol[IntType]("i"+(dim+1)) @@ -36,8 +36,8 @@ class InnerProduct(left: Field, right: Field) extends Scalar { context += new AssignStatement(result, new FloatLiteral(0.0)) context += loops(2) - val leftIndex = for (dim <- 0 to 2) yield indices(dim) - leftOrigin(dim) - val rightIndex = for (dim <- 0 to 2) yield indices(dim) - rightOrigin(dim) + val leftIndex = for (dim <- 0 to 2) yield indices(dim) - leftOrigin(dim) + 1 + val rightIndex = for (dim <- 0 to 2) yield indices(dim) - rightOrigin(dim) + 1 loops(0) += new AssignStatement(result, (result : Expression[FloatType]) + leftDense.getBuffer.at(leftIndex: _*) *