Hi there,
I am curious about TFG’s designed representation of tensors. From the code, I found that tensor is represented as an attribute of the tfg.op.  The code is like below:
// tensorflow/core/ir/importexport/convert_tensor.h
// Converts an TensorFlow tensor proto into an MLIR elements attribute.
tensorflow::StatusOr<ElementsAttr> ConvertTensorProto(
    const tensorflow::TensorProto& input_tensor, Builder builder,
    TFGraphDialect* tfgDialect);

From the above code, a tensorflow tensor is converted to mlir::ElementsAttr for a specific op.  This would be an attribute for the op node.
However, MLIR attributes 1 read following:

attributes are compile-time known constant values

So, from my understanding,  tfg does not allow modifying the tensor’s data, because the tensor attribute should be constant value.
In that case, Are the following understanding correct?


tfg by design does not allow optimizations like constant_folding, which  would modify tensor’s data. (Or have to recreate a new node and replace the old one).
Why not create a  type instead of attribute in TFG MLIR? As type would allow mutable part 1 listed in the link.
Similar design appreas on ShapeAttr , it also does not have the setShape method, meaning this by design could not be modified.

As tfg is designed to replace grappler, in grappler, it could easily change those things in NodeDef, how could tfg do these things? Should tfg always create a new node and replace the old one?