Skip to content

Cleanup #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mlir/include/mlir/Dialect/Tosa/Transforms/TosaFoldCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
namespace mlir {
namespace tosa {

// Transform a tensor with the given transformation function.
/// Transform a tensor with the given transformation function.
DenseElementsAttr applyElementWise(
const DenseElementsAttr &toTransform,
const std::function<llvm::APFloat(const llvm::APFloat &, Type)> &toApply);

/// Function that checks if arg is a dense TOSA constant float tensor
/// Function that checks if \p toCheck is a dense TOSA constant float tensor.
LogicalResult notifyIfNotConstantFloatTosaTensor(TypedValue<TensorType> toCheck,
TosaOp location,
PatternRewriter &);

/// Function that checks if arg is a dense TOSA constant tensor
/// Function that checks if \p toCheck is a dense TOSA constant tensor.
LogicalResult notifyIfNoTosaDenseConstantTensor(TypedValue<TensorType> toCheck,
TosaOp location,
PatternRewriter &);

/// Function that checks if the contained type is float
/// Function that checks if the type contained in \p toCheck is float.
LogicalResult notifyIfNotFloat(TypedValue<TensorType> toCheck, TosaOp location,
PatternRewriter &);

/// Function to compute the reciprocal
/// Function to compute the reciprocal.
APFloat computeReciprocal(const APFloat &, Type);

} // namespace tosa
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Tosa/Transforms/TosaFoldCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ DenseElementsAttr mlir::tosa::applyElementWise(
// all of them to avoid dynamic resizing
transformedValues.reserve(toTransform.getNumElements());
for (auto val : toTransform.getValues<llvm::APFloat>()) {
auto recipVal = toApply(val, toTransform.getElementType());
transformedValues.push_back(recipVal);
auto transformedVal = toApply(val, toTransform.getElementType());
transformedValues.push_back(transformedVal);
}

// Replace the current tensor with one containing the computed reciprocals
// Replace the current tensor with one containing the computed values
auto newTensor =
DenseElementsAttr::get(toTransform.getType(), transformedValues);
return newTensor;
Expand Down