This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Adapt yaml codegen to support scalar parameters.
ClosedPublic

Authored by gysit on Jun 14 2021, 6:24 AM.

Details

Summary

The patch updates the C++ yaml code generation to support scalar operands as added in https://reviews.llvm.org/D104220.

Diff Detail

Event Timeline

gysit created this revision.Jun 14 2021, 6:24 AM
gysit requested review of this revision.Jun 14 2021, 6:24 AM

Mind rebasing this on head? Presubmits are failing due to not being on a commited CL.

stellaraccident accepted this revision.Jun 14 2021, 9:53 PM

Some nits and notes for the future. I like that this enables scalars and is much simpler than where the capture work was headed.

mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
113–115

Need to verify with the rest of this patch that this change in dims is intentional.

mlir/test/python/dialects/linalg/opsrun.py
134

Note for a follow-on patch: I believe this test file should be moved to the integration test directory.

mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
116

Why switch this to an std::vector? (I know there are valid reasons to do so in this module, such as with type recursion, but I'm not seeing the rationale for this case)

152–153

I believe you removed the temporary option above. Remove from this (now stale) comment?

This revision is now accepted and ready to land.Jun 14 2021, 9:53 PM
gysit updated this revision to Diff 352074.Jun 15 2021, 2:09 AM

Address comments.

gysit marked 2 inline comments as done.Jun 15 2021, 2:30 AM
gysit added inline comments.
mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
113–115

I swapped the shape since the input I is read transposed (the indexing map is also swapped). It has no direct effect here since we only test the yaml to c++ translation.

mlir/test/python/dialects/linalg/opsrun.py
134

@stellaraccident Would you move it under a new integration test directory in the python subfolder (e.g. mlir/python/test/integration) or in the existing integration test directory (e.g. mlir/test/integration). I think having all python code in the same subfolder (mlir/python/) seems preferable?

mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
116

When using SmallVector<ScalarAssign> I ran into a problem with a static assert checking the size (on Windows only). Setting a fixed size resolved the problem and may overall be more consistent. I just thought std::vector is more on the safe side since struct is big (close to 256 Byte). But assuming the parent struct is most likely heap allocated I think using inline storage is fine.

mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
116

Thanks and sg. It is fine to leave it as vector given this. Was just wondering the rationale for the change.

gysit updated this revision to Diff 352121.Jun 15 2021, 6:31 AM
gysit marked an inline comment as done.

Address comment.