Skip to content

Commit 4205c50

Browse files
committed
Removing the requirment for optional attributes to have a value
1 parent 6c53dd9 commit 4205c50

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/TensorFlowNET.Core/Operations/OpDefLibrary.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,18 @@ public Operation _apply_op_helper(string op_type_name, string name = null, Dicti
160160

161161
// Convert attr values to AttrValue protos.
162162
var attr_protos = new Dictionary<string, AttrValue>();
163-
foreach (var attr_def in op_def.Attr)
163+
foreach (AttrDef attr_def in op_def.Attr)
164164
{
165165
var key = attr_def.Name;
166-
var value = attrs[key];
167-
168-
if (!attrs.ContainsKey(key))
169-
Console.WriteLine($"_apply_op_helper: key '{key}' is not found in '{op_def.Name}' operation's attr_def.");
170-
171-
attr_protos[key] = SetAttrValue(op_def, attr_def, value);
166+
if (attrs.ContainsKey(key))
167+
{
168+
attr_protos[key] = SetAttrValue(op_def, attr_def, attrs[key]);
169+
} else {
170+
if (attr_def.DefaultValue == null)
171+
{
172+
throw new TypeError("Missing required positional argument " + key);
173+
}
174+
}
172175
}
173176

174177
attrs.Clear();

0 commit comments

Comments
 (0)