Lines Matching +full:batch +full:- +full:reduce

1 //===- TosaToLinalg.cpp - Lowering Tosa to Linalg Dialect -----------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
44 cast<IntegerAttr>(op->getAttr(attrName)).getValue().getSExtValue());
46 op->getLoc(), IntegerAttr::get(requiredAttrType, castedN));
52 Location loc = op->getLoc();
54 cast<ShapedType>(op->getOperand(0).getType()).getElementType();
170 // it. We assume 48-bit numbers may be supported further in the pipeline.
185 // outputValue = inZp + outZp - inputValue
234 auto round = cast<BoolAttr>(op->getAttr("round")).getValue();
256 ->getResults();
354 elementTy = cast<ShapedType>(op->getOperand(1).getType()).getElementType();
388 APFloat minApf = cast<FloatAttr>(op->getAttr("min_fp")).getValue();
389 APFloat maxApf = cast<FloatAttr>(op->getAttr("max_fp")).getValue();
404 cast<IntegerAttr>(op->getAttr("min_int")).getValue().getSExtValue();
406 cast<IntegerAttr>(op->getAttr("max_int")).getValue().getSExtValue();
418 // Ensure that min & max fit into signed n-bit constants.
424 // Ensure that the bounds are representable as n-bit signed/unsigned
467 // 1-bit integers need to be treated as signless.
489 // All other si-to-fp conversions should be handled by SIToFP.
494 // Casting to boolean, floats need to only be checked as not-equal to zero.
507 // input floating-point type due to too short exponent range.
508 if (static_cast<int>(dstTy.getIntOrFloatBitWidth()) - 1 >
546 dstTy.getIntOrFloatBitWidth() - 1) {
549 // in the floating-point domain.
588 // Casting to boolean, integers need to only be checked as not-equal to
617 int64_t numExtraDims = rank - tensorRank;
664 it->second =
666 return it->second;
690 return llvm::all_of(operation->getOperands(), isRanked) &&
691 llvm::all_of(operation->getResults(), isRanked);
881 converter.convertType(operation->getResultTypes().front()));
917 operation, blockArgs.take_front(operation->getNumOperands()),
931 loc, resultType, linalgOp->getResult(0));
942 assert(operation->getNumResults() == 1 && "elementwise op expects 1 result");
943 assert(operation->getNumOperands() >= 1 &&
951 auto loc = operation->getLoc();
953 cast<RankedTensorType>(operation->getResultTypes().front()).getRank();
1027 Location loc = op->getLoc();
1074 auto loc = op->getLoc();
1075 auto inputTy = cast<ShapedType>(op->getOperand(0).getType());
1076 auto resultTy = cast<ShapedType>(op->getResult(0).getType());
1078 Value input = op->getOperand(0);
1122 op, "unable to create linalg.generic body for reduce op");
1135 int32_t expandedDim = axis < expandInputRank ? axis : expandInputRank - 1;
1161 op, operands.getOperands(), rewriter, *this->getTypeConverter());
1214 // If we are rescaling per-channel then we need to store the multiplier
1223 rewriter.getAffineDimExpr(rank - 1)};
1234 multiplierArg = indexingMaps.size() - 1;
1237 // If we are rescaling per-channel then we need to store the shift
1246 rewriter.getAffineDimExpr(rank - 1)};
1255 shiftArg = indexingMaps.size() - 1;
1274 // For now we do all of our math in 64-bit. This is not optimal but
1306 // Move to the new zero-point.
1341 rewriter.replaceOp(op, linalgOp->getResults());
1369 op, "tosa.resize is not a pure 1x1->1x1 image operation");
1462 auto batch = inputTy.getDimSize(0);
1476 resizeShape.push_back(batch);
1483 builder.create<tosa::ResizeOp>(resizeTy, input, op->getAttrs());
1496 llvm::SmallVector<int64_t> collapseShape = {batch};
1584 Value batch = b.create<linalg::IndexOp>(0);
1592 Value hMax = b.create<arith::ConstantOp>(b.getI32IntegerAttr(imageH - 1));
1593 Value wMax = b.create<arith::ConstantOp>(b.getI32IntegerAttr(imageW - 1));
1637 // Compute the ix and dx values for the X and Y dimensions - int case.
1648 // dx = x - ix * scale_n;
1670 ImplicitLocOpBuilder &b) -> Value {
1695 input, ValueRange{batch, iy, ix, channel});
1718 // int16_t iy1 = apply_min(iy + 1, IH - 1);
1720 // int16_t ix1 = apply_min(ix + 1, IW - 1);
1726 input, ValueRange{batch, y0, x0, channel});
1728 input, ValueRange{batch, y0, x1, channel});
1730 input, ValueRange{batch, y1, x0, channel});
1732 input, ValueRange{batch, y1, x1, channel});
1739 ImplicitLocOpBuilder &b) -> Value {
1749 // topAcc = v00 * (unit_x - dx);
1754 // bottomAcc = v10 * (unit_x - dx);
1759 // result = topAcc * (unit_y - dy) + bottomAcc * dy
1787 ImplicitLocOpBuilder &b) -> Value {
1811 // where identity is load-bearing (e.g. cross device computation) should be
1820 rewriter.replaceOp(op, op.getOperation()->getOperands());
1896 // proceding size-1 dim. This dim is then broadcasted to the appropriate
1920 genericShape.push_back(dim == -1 ? ShapedType::kDynamic : dim);
1926 if (inputTy.isDynamicDim(i) || multiples[i] == -1) {
1934 // We needs to map the input shape to the non-broadcasted dimensions.
1993 "tosa.arg_max to linalg.* requires integer-like result type");
2035 // We need to reduce along the arg-max axis, with parallel operations along
2214 auto inputValue = block->getArgument(0);
2273 // result = (base << 7) + (next - base) * fraction
2313 // Set W = (W / 2) + 1 to account for the half-sized W dimension of the
2363 if (!llvm::all_of(rfft2d->getOperandTypes(), isRankedTensor) ||
2364 !llvm::all_of(rfft2d->getResultTypes(), isRankedTensor)) {
2448 // outImag = sumImag - imagComponent
2468 if (!llvm::all_of(fft2d->getOperandTypes(),
2470 !llvm::all_of(fft2d->getResultTypes(),
2567 loc, rewriter.getFloatAttr(real_el_ty, -1.0)));
2571 // imagComponent = -val_real * sin(a) + val_imag * cos(a);
2585 // outImag = sumImag - imagComponent
2606 patterns->add<GenericResizeConverter>(patterns->getContext(),
2608 patterns->add<ResizeUnaryConverter>(patterns->getContext(),
2610 patterns->add<MaterializeResizeBroadcast>(patterns->getContext(),
2613 patterns->add<
2614 // clang-format off
2653 >(converter, patterns->getContext());
2655 patterns->add<
2670 TileConverter>(patterns->getContext());
2671 // clang-format on