This is an archive of the discontinued LLVM Phabricator instance.

Refactor TensorExp parameters into a union
ClosedPublic

Authored by gussmith23 on Jul 1 2021, 11:48 AM.

Details

Summary

To make TensorExp clearer, this change refactors the e0/e1 fields into a union: e0/e1 for a binary op tensor expression, and tensor_num for a tensor-kinded tensor expression.

Diff Detail

Event Timeline

gussmith23 created this revision.Jul 1 2021, 11:48 AM
gussmith23 requested review of this revision.Jul 1 2021, 11:48 AM
aartbik added inline comments.Jul 1 2021, 11:53 AM
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
55–61

can we make this an anonymous struct, defined inline, so that at least we don't need the xxx.params.yyy everywhere?

aartbik added inline comments.Jul 1 2021, 12:28 PM
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
32

also, just call this tensor

(the _ in the name is against our style, but the use of just tensor is also consistent with comments and code elsewhere)

Make union anonymous; rename tensor_num->tensor

gussmith23 marked 2 inline comments as done.Jul 1 2021, 12:48 PM

Make struct anonymous

aartbik accepted this revision.Jul 1 2021, 12:58 PM
aartbik added inline comments.
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
55–61

I would remove this comment completely, since that is true for all fields of this struct

You have adequate comments inside the union

This revision is now accepted and ready to land.Jul 1 2021, 12:58 PM
gussmith23 updated this revision to Diff 355993.Jul 1 2021, 1:01 PM
gussmith23 marked an inline comment as done.

Remove comment

gussmith23 updated this revision to Diff 356007.Jul 1 2021, 1:47 PM

Fix clang-tidy

gussmith23 updated this revision to Diff 356014.Jul 1 2021, 2:21 PM

Again, attempt to fix clang-tidy

aartbik added inline comments.Jul 1 2021, 2:38 PM
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
55–61

assuming clang tidy accepts this, this will need to move up in the struct (or perhaps even outside for readability), since within classes/structs, typedefs should go first

gussmith23 updated this revision to Diff 356018.Jul 1 2021, 2:45 PM

Move struct outside

Fix after rebase

This revision was automatically updated to reflect the committed changes.