MLBEDSW-7613: Crash when compiling model with resource variables

Fixed serializing of attribute container and shared_name that
accidently got lost when fixing the crash for a faulty LSTM model.

Change-Id: Ibd11da65735112bed4b1c8bcc4ef048bc093ebc4
Signed-off-by: Johan Alfven <johan.alfven@arm.com>
diff --git a/ethosu/vela/tflite_writer.py b/ethosu/vela/tflite_writer.py
index 8c03f05..ae529a4 100644
--- a/ethosu/vela/tflite_writer.py
+++ b/ethosu/vela/tflite_writer.py
@@ -314,12 +314,14 @@
                     attrs["dilation_w_factor"] = attrs["dilation"][2]
                 if "channel_multiplier" in attrs:
                     attrs["depth_multiplier"] = attrs["channel_multiplier"]
-                if "container" in attrs:
-                    attrs["container"] = builder.CreateString(attrs["container"])
-                if "shared_name" in attrs:
-                    attrs["shared_name"] = builder.CreateString(attrs["shared_name"])
                 attrs["fused_activation_function"] = op.activation.op_type if op.activation is not None else None
 
+            # Serialize VarHandleOptions (only op that have attributes with type String)
+            if "container" in attrs:
+                attrs["container"] = builder.CreateString(attrs["container"])
+            if "shared_name" in attrs:
+                attrs["shared_name"] = builder.CreateString(attrs["shared_name"])
+
             builtin_opt_offset, custom_opt_offset = opt_serializer.serialize(builder, attrs)
 
             # report any missing attributes that could not be written during serialize().