onnxruntime/js/react_native/ios/TensorHelper.h
Sunghoon 88d2fc8f1e
ONNX Runtime React Native Library (#7564)
* onnxruntime react native binding

* add react native backend

* fix lint comments

* fix react native backend for ios

* remove unnecessary files to check in

* move onnxruntime-common to devDependency

* create two podspec files for iphoneos and iphonesimulator

* revise README.md and add third party notices for react native

* rename a package

* rename a package and revise README

* add a license into package.json

* revise README and comments

* fix typo

* fix lint errors

* fix lint errors

* add a prepack script. touch index.tsx and App.tsx to resolve CI issue

* remove a unsupported tsx format from clang-format

* fix a type and add steps tp publish a react native npm package

* resolve comments

* fix clang format

* remove promise wrap. change prepack to typescript
2021-05-11 10:34:40 -07:00

41 lines
1.3 KiB
Objective-C

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef TensorHelper_h
#define TensorHelper_h
#import <Foundation/Foundation.h>
#import "onnxruntime_cxx_api.h"
@interface TensorHelper : NSObject
/**
* Supported tensor data type
*/
FOUNDATION_EXPORT NSString* const JsTensorTypeBool;
FOUNDATION_EXPORT NSString* const JsTensorTypeByte;
FOUNDATION_EXPORT NSString* const JsTensorTypeShort;
FOUNDATION_EXPORT NSString* const JsTensorTypeInt;
FOUNDATION_EXPORT NSString* const JsTensorTypeLong;
FOUNDATION_EXPORT NSString* const JsTensorTypeFloat;
FOUNDATION_EXPORT NSString* const JsTensorTypeDouble;
FOUNDATION_EXPORT NSString* const JsTensorTypeString;
/**
* It creates an input tensor from a map passed by react native js.
* 'data' must be a string type as data is encoded as base64. It first decodes it and creates a tensor.
*/
+(Ort::Value)createInputTensor:(NSDictionary*)input
ortAllocator:(OrtAllocator*)ortAllocator
allocations:(std::vector<Ort::MemoryAllocation>&)allocatons;
/**
* It creates an output map from an output tensor.
* a data array is encoded as base64 string.
*/
+(NSDictionary*)createOutputTensor:(const std::vector<const char*>&)outputNames
values:(const std::vector<Ort::Value>&)values;
@end
#endif /* TensorHelper_h */