From 8ec583f0f277745f848b09977b5a51bed7e50564 Mon Sep 17 00:00:00 2001 From: Duy Mai M Date: Wed, 7 Feb 2024 15:02:51 +0700 Subject: [PATCH] fix dart format --- lib/src/interpreter.dart | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/src/interpreter.dart b/lib/src/interpreter.dart index bb6a8e2..0efabaa 100644 --- a/lib/src/interpreter.dart +++ b/lib/src/interpreter.dart @@ -16,7 +16,6 @@ import 'dart:ffi'; import 'dart:io'; -import 'dart:collection'; import 'package:ffi/ffi.dart'; import 'package:flutter/services.dart'; @@ -212,14 +211,10 @@ class Interpreter { inputTensors.elementAt(i).setTo(inputs[i]); } - var inferenceStartNanos = DateTime - .now() - .microsecondsSinceEpoch; + var inferenceStartNanos = DateTime.now().microsecondsSinceEpoch; invoke(); _lastNativeInferenceDurationMicroSeconds = - DateTime - .now() - .microsecondsSinceEpoch - inferenceStartNanos; + DateTime.now().microsecondsSinceEpoch - inferenceStartNanos; } /// Gets all input tensors associated with the model. @@ -230,9 +225,8 @@ class Interpreter { var tensors = List.generate( tfliteBinding.TfLiteInterpreterGetInputTensorCount(_interpreter), - (i) => - Tensor( - tfliteBinding.TfLiteInterpreterGetInputTensor(_interpreter, i)), + (i) => Tensor( + tfliteBinding.TfLiteInterpreterGetInputTensor(_interpreter, i)), growable: false); return tensors; @@ -246,10 +240,8 @@ class Interpreter { var tensors = List.generate( tfliteBinding.TfLiteInterpreterGetOutputTensorCount(_interpreter), - (i) => - Tensor( - tfliteBinding.TfLiteInterpreterGetOutputTensor( - _interpreter, i)), + (i) => Tensor( + tfliteBinding.TfLiteInterpreterGetOutputTensor(_interpreter, i)), growable: false); return tensors; @@ -260,7 +252,7 @@ class Interpreter { final dimensionSize = shape.length; final dimensions = calloc(dimensionSize); final externalTypedData = - dimensions.cast().asTypedList(dimensionSize); + dimensions.cast().asTypedList(dimensionSize); externalTypedData.setRange(0, dimensionSize, shape); final status = tfliteBinding.TfLiteInterpreterResizeInputTensor( _interpreter, tensorIndex, dimensions, dimensionSize); @@ -348,7 +340,7 @@ class Interpreter { // check if signature key exists if (!_signatureRunners.containsKey(signatureKey)) { Pointer signatureKeyPointer = - signatureKey.toNativeUtf8() as Pointer; + signatureKey.toNativeUtf8() as Pointer; final signatureRunner = tfliteBinding.TfLiteInterpreterGetSignatureRunner( _interpreter, signatureKeyPointer); _signatureRunners[signatureKey] = signatureRunner; @@ -362,7 +354,7 @@ class Interpreter { int getSignatureInputCount(String signatureKey) { final signatureRunner = _getSignatureRunner(signatureKey); final subGraphIndex = - tfliteBinding.TfLiteSignatureRunnerGetInputCount(signatureRunner); + tfliteBinding.TfLiteSignatureRunnerGetInputCount(signatureRunner); return subGraphIndex; } @@ -370,7 +362,7 @@ class Interpreter { int getSignatureOutputCount(String signatureKey) { final signatureRunner = _getSignatureRunner(signatureKey); final subGraphIndex = - tfliteBinding.TfLiteSignatureRunnerGetOutputCount(signatureRunner); + tfliteBinding.TfLiteSignatureRunnerGetOutputCount(signatureRunner); return subGraphIndex; } @@ -378,7 +370,7 @@ class Interpreter { String getSignatureInputName(String signatureKey, int index) { final signatureRunner = _getSignatureRunner(signatureKey); final inputName = - tfliteBinding.TfLiteSignatureRunnerGetInputName(signatureRunner, index); + tfliteBinding.TfLiteSignatureRunnerGetInputName(signatureRunner, index); return inputName.cast().toDartString(); } @@ -390,8 +382,8 @@ class Interpreter { return outputName.cast().toDartString(); } - List getSignatureInputTensorShape(String signatureKey, - String inputName) { + List getSignatureInputTensorShape( + String signatureKey, String inputName) { final signatureRunner = _getSignatureRunner(signatureKey); final inputTensor = Tensor( tfliteBinding.TfLiteSignatureRunnerGetInputTensor( @@ -400,8 +392,8 @@ class Interpreter { return shape; } - List getSignatureOutputTensorShape(String signatureKey, - String outputName) { + List getSignatureOutputTensorShape( + String signatureKey, String outputName) { final signatureRunner = _getSignatureRunner(signatureKey); final outputTensor = Tensor( tfliteBinding.TfLiteSignatureRunnerGetOutputTensor( @@ -421,7 +413,7 @@ class Interpreter { } final Pointer signatureRunner = - _getSignatureRunner(signatureKey); + _getSignatureRunner(signatureKey); inputs.forEach((key, value) { Tensor inputTensor = Tensor(