Skip to content

Commit 8acdb03

Browse files
vladimirostermigueldeicaza
authored andcommitted
Adding GetAttributeType method to query for Type attributes (migueldeicaza#353)
1 parent 8dd21fc commit 8acdb03

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

TensorFlowSharp/Tensorflow.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,21 @@ public TFAttributeMetadata GetAttributeMetadata (string attrName, TFStatus statu
22322232
// extern void TF_OperationGetAttrType (TF_Operation *oper, const char *attr_name, TF_DataType *value, TF_Status *status);
22332233
[DllImport (NativeBinding.TensorFlowLibrary)]
22342234
static extern unsafe void TF_OperationGetAttrType (TF_Operation oper, string attr_name, TFDataType* value, TF_Status status);
2235-
// TODO:
2235+
2236+
/// <summary>
2237+
/// Query the operation for a type attribute
2238+
/// </summary>
2239+
/// <value>The value (type) of the attribute.</value>
2240+
public unsafe TFDataType GetAttributeType (string attrName, TFStatus status = null)
2241+
{
2242+
if (handle == IntPtr.Zero)
2243+
TFDisposable.ObjectDisposedException ();
2244+
var cstatus = TFStatus.Setup (status);
2245+
TFDataType type_value = new TFDataType ();
2246+
TF_OperationGetAttrType (handle, attrName, &type_value, cstatus.Handle);
2247+
cstatus.CheckMaybeRaise (status);
2248+
return type_value;
2249+
}
22362250

22372251
// extern void TF_OperationGetAttrTypeList (TF_Operation *oper, const char *attr_name, TF_DataType *values, int max_values, TF_Status *status);
22382252
[DllImport (NativeBinding.TensorFlowLibrary)]

0 commit comments

Comments
 (0)