Skip to content

Commit

Permalink
Fix TfLiteSignatureRunnerGetInputCount return type to match with C API
Browse files Browse the repository at this point in the history
  • Loading branch information
asus4 committed Oct 17, 2024
1 parent dd7577d commit b3fe9af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public static void LogIOInfo(this SignatureRunner runner)
}
sb.AppendLine();

int signatureInputCount = runner.GetSignatureInputCount();
int signatureInputCount = (int)runner.GetSignatureInputCount();
for (int i = 0; i < signatureInputCount; i++)
{
string name = runner.GetSignatureInputName(i);
sb.AppendLine($"Signature Input [{i}]: {name},\t info: {runner.GetSignatureInputInfo(name)}");
}
sb.AppendLine();

int signatureOutputCount = runner.GetSignatureOutputCount();
int signatureOutputCount = (int)runner.GetSignatureOutputCount();
for (int i = 0; i < signatureOutputCount; i++)
{
string name = runner.GetSignatureOutputName(i);
Expand Down
10 changes: 5 additions & 5 deletions Packages/com.github.asus4.tflite/Runtime/SignatureRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public string GetSignatureKey(int index)
return ToString(TfLiteInterpreterGetSignatureKey(InterpreterPointer, index));
}

public int GetSignatureInputCount()
public ulong GetSignatureInputCount()
{
return TfLiteSignatureRunnerGetInputCount(runner);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public override void Invoke()
ThrowIfError(TfLiteSignatureRunnerInvoke(runner));
}

public int GetSignatureOutputCount()
public ulong GetSignatureOutputCount()
{
return TfLiteSignatureRunnerGetOutputCount(runner);
}
Expand Down Expand Up @@ -199,7 +199,7 @@ private void Initialize(string signatureName)

private Dictionary<string, int> CreateMap(bool isInput)
{
int signatureCount = isInput ? GetSignatureInputCount() : GetSignatureOutputCount();
int signatureCount = (int)(isInput ? GetSignatureInputCount() : GetSignatureOutputCount());
int tensorCount = isInput ? GetInputTensorCount() : GetOutputTensorCount();
Assert.AreEqual(signatureCount, tensorCount);

Expand Down Expand Up @@ -270,7 +270,7 @@ private Dictionary<string, int> CreateMap(bool isInput)
private static extern TfLiteSignatureRunner TfLiteInterpreterGetSignatureRunner(TfLiteInterpreter interpreter, string signature_name);

[DllImport(TensorFlowLibrary)]
private static extern int TfLiteSignatureRunnerGetInputCount(TfLiteSignatureRunner signature_runner);
private static extern ulong TfLiteSignatureRunnerGetInputCount(TfLiteSignatureRunner signature_runner);

[DllImport(TensorFlowLibrary)]
private static extern IntPtr TfLiteSignatureRunnerGetInputName(TfLiteSignatureRunner signature_runner, int input_index);
Expand All @@ -290,7 +290,7 @@ private static extern Status TfLiteSignatureRunnerResizeInputTensor(
private static extern Status TfLiteSignatureRunnerInvoke(TfLiteSignatureRunner signature_runner);

[DllImport(TensorFlowLibrary)]
private static extern int TfLiteSignatureRunnerGetOutputCount(TfLiteSignatureRunner signature_runner);
private static extern ulong TfLiteSignatureRunnerGetOutputCount(TfLiteSignatureRunner signature_runner);

[DllImport(TensorFlowLibrary)]
private static extern IntPtr TfLiteSignatureRunnerGetOutputName(TfLiteSignatureRunner signature_runner, int output_index);
Expand Down

0 comments on commit b3fe9af

Please sign in to comment.