Allow this usage in the rewrite pattern
def replacement(x):
tensor = ir.tensor(..., name="new_name")
return op.Add(op.Initializer(tensor), x)
def replacement_when_y_is_const_node(x):
# Q: How do I get that const node?
...
def replacement_transpose_initializer(x):
tensor = x.const_value
transposed = ir.tensor(tensor.numpy().T)
return op.Initializer(transposed)
def Initializer(tensor: ir.TensorProtocol, name: str | None = None) -> ir.Value:
# When name is None, the value name will be taken from the tensor
# Otherwise the name is specified in name
# Optionally we can also generate a name if nothing is specified, but I am not sure if that's error-prone
...
cc @gramalingam @kunal-vaishnavi