This is an archive of the discontinued LLVM Phabricator instance.

[ODS] Use Adaptor Traits for Type Inference
ClosedPublic

Authored by amandatang on Jul 12 2023, 1:33 PM.

Details

Summary

Author inferReturnTypes methods with the Op Adaptor by using the InferTypeOpAdaptor.

Diff Detail

Event Timeline

amandatang created this revision.Jul 12 2023, 1:33 PM
Herald added a reviewer: jpienaar. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
amandatang requested review of this revision.Jul 12 2023, 1:33 PM
amandatang added a reviewer: okwank. amandatang removed 1 blocking reviewer(s): jpienaar.Jul 13 2023, 9:37 AM

Use function overloading

jpienaar added inline comments.Jul 17 2023, 9:10 AM
mlir/test/lib/Dialect/Test/TestDialect.cpp
1392

Is getX and getY general here?

amandatang added inline comments.Jul 17 2023, 9:19 AM
mlir/test/lib/Dialect/Test/TestDialect.cpp
1392

No, the arguments of OpWithInferTypeAdaptorInterfaceOp are named x and y.

jpienaar accepted this revision.Jul 18 2023, 10:55 AM
This revision is now accepted and ready to land.Jul 18 2023, 10:55 AM
This revision was automatically updated to reflect the committed changes.

This broke the bot, can you fix or revert?

https://lab.llvm.org/buildbot/#/builders/61/builds/46176

+ /vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py
error: missing shape attribute
Traceback (most recent call last):
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 17, in <module>
    def testConstShape():
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 11, in run
    f()
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 26, in testConstShape
    def const_shape_tensor(arg):
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/tools/mlir/python_packages/mlir_core/mlir/dialects/_func_ops_ext.py", line 190, in decorator
    return_values = f(*func_args, **func_kwargs)
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 30, in const_shape_tensor
    x = shape.ConstShapeOp([1, 2])
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/tools/mlir/python_packages/mlir_core/mlir/dialects/_shape_ops_gen.py", line 278, in __init__
    results = _ods_ir.InferTypeOpInterface(ConstShapeOp).inferReturnTypes(
ValueError: Failed to infer result types

This broke the bot, can you fix or revert?

https://lab.llvm.org/buildbot/#/builders/61/builds/46176

+ /vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/bin/FileCheck /vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py
error: missing shape attribute
Traceback (most recent call last):
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 17, in <module>
    def testConstShape():
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 11, in run
    f()
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 26, in testConstShape
    def const_shape_tensor(arg):
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/tools/mlir/python_packages/mlir_core/mlir/dialects/_func_ops_ext.py", line 190, in decorator
    return_values = f(*func_args, **func_kwargs)
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.src/mlir/test/python/dialects/shape.py", line 30, in const_shape_tensor
    x = shape.ConstShapeOp([1, 2])
  File "/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/tools/mlir/python_packages/mlir_core/mlir/dialects/_shape_ops_gen.py", line 278, in __init__
    results = _ods_ir.InferTypeOpInterface(ConstShapeOp).inferReturnTypes(
ValueError: Failed to infer result types

Yes, I'm investigating the error now.

Here's a patch that fixes the issue: https://reviews.llvm.org/D155637