[Mlir-commits] [mlir] [MLIR][Python] enhance python api for tensor.empty (PR #103087)
Maksim Levental
llvmlistbot at llvm.org
Tue Aug 13 11:51:56 PDT 2024
================
@@ -43,6 +44,18 @@ def __init__(
super().__init__(result_type, dynamic_sizes, loc=loc, ip=ip)
+def empty(
+ sizes: Sequence[Union[int, Value]],
+ element_type: Type,
+ *,
+ loc=None,
+ ip=None,
+) -> _ods_cext.ir.Value:
+ return _get_op_result_or_op_results(
+ EmptyOp(sizes=sizes, element_type=element_type, loc=loc, ip=ip)
+ )
----------------
makslevental wrote:
Doesn't this already exist? I.e. this should already be generated (with basically this exact same signature):
```
# tensor.py
@_ods_cext.register_operation(_Dialect)
class EmptyOp(_ods_ir.OpView):
OPERATION_NAME = "tensor.empty"
_ODS_REGIONS = (0, True)
def __init__(self, result, dynamicSizes, *, loc=None, ip=None):
operands = []
results = []
attributes = {}
regions = None
operands.extend(_get_op_results_or_values(dynamicSizes))
_ods_context = _ods_get_default_loc_context(loc)
results.append(result)
_ods_successors = None
super().__init__(self.build_generic(attributes=attributes, results=results, operands=operands, successors=_ods_successors, regions=regions, loc=loc, ip=ip))
def empty(result, dynamic_sizes, *, loc=None, ip=None) -> _ods_ir.Value:
return _get_op_result_or_op_results(EmptyOp(result=result, dynamicSizes=dynamic_sizes, loc=loc, ip=ip))
```
https://github.com/llvm/llvm-project/pull/103087
More information about the Mlir-commits
mailing list