コード例 #1
0
        public static void SetOpAttrs(TFE_Op op, params object[] attrs)
        {
            using var status = new Status();
            var len = attrs.Length;

            for (int i = 0; i < len; i += 2)
            {
                var key   = attrs[i].ToString();
                var value = attrs[i + 1];

                byte is_list = 0;
                var  type    = c_api.TFE_OpGetAttrType(op, key, ref is_list, status);
                if (!status.ok())
                {
                    return;
                }
                if (is_list != 0)
                {
                    SetOpAttrList(tf.context, op, key, value, type, null, status);
                }
                else
                {
                    SetOpAttrScalar(tf.context, op, key, value, type, null, status);
                }
                status.Check(true);
            }
        }
コード例 #2
0
        private static void SetOpAttrs(Context ctx, TFE_Op op, object[] attrs, int start_index, Status out_status)
        {
            var len = attrs.Length;

            for (int i = 0; i < len; i += 2)
            {
                var key   = attrs[start_index + i].ToString();
                var value = attrs[start_index + i + 1];

                byte is_list = 0;
                var  type    = c_api.TFE_OpGetAttrType(op, key, ref is_list, out_status);
                if (!out_status.ok())
                {
                    return;
                }
                if (is_list != 0)
                {
                    SetOpAttrList(ctx, op, key, value, type, null, out_status);
                }
                else
                {
                    SetOpAttrScalar(ctx, op, key, value, type, null, out_status);
                }
                out_status.Check(true);
            }
        }