diff --git a/src/finn/custom_op/__init__.py b/src/finn/custom_op/__init__.py
index fdbd7a17fd035e49515f656abbf9470b855dc636..519d48e97075c6e6be57d187720269ac08312028 100644
--- a/src/finn/custom_op/__init__.py
+++ b/src/finn/custom_op/__init__.py
@@ -38,6 +38,9 @@ class CustomOp(ABC):
             if attr is not None:
                 # dtype indicates which ONNX Attribute member to use
                 # (such as i, f, s...)
+                if dtype == "s":
+                    # encode string attributes
+                    value = value.encode("utf-8")
                 attr.__setattr__(dtype, value)
             else:
                 # not set, create and insert AttributeProto