2020-05-05 18:45:12 +00:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <napi.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "onnxruntime_cxx_api.h"
|
|
|
|
|
|
|
|
|
|
// convert a Javascript OnnxValue object to an OrtValue object
|
2024-11-04 21:09:07 +00:00
|
|
|
Ort::Value NapiValueToOrtValue(Napi::Env env, Napi::Value value, OrtMemoryInfo* cpu_memory_info, OrtMemoryInfo* webgpu_memory_info);
|
2020-05-05 18:45:12 +00:00
|
|
|
|
|
|
|
|
// convert an OrtValue object to a Javascript OnnxValue object
|
2024-11-04 21:09:07 +00:00
|
|
|
Napi::Value OrtValueToNapiValue(Napi::Env env, Ort::Value&& value);
|
|
|
|
|
|
|
|
|
|
enum DataLocation {
|
|
|
|
|
DATA_LOCATION_NONE = 0,
|
|
|
|
|
DATA_LOCATION_CPU = 1,
|
|
|
|
|
DATA_LOCATION_CPU_PINNED = 2,
|
|
|
|
|
DATA_LOCATION_TEXTURE = 3,
|
|
|
|
|
DATA_LOCATION_GPU_BUFFER = 4,
|
|
|
|
|
DATA_LOCATION_ML_TENSOR = 5
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline DataLocation ParseDataLocation(const std::string& location) {
|
|
|
|
|
if (location == "cpu") {
|
|
|
|
|
return DATA_LOCATION_CPU;
|
|
|
|
|
} else if (location == "cpu-pinned") {
|
|
|
|
|
return DATA_LOCATION_CPU_PINNED;
|
|
|
|
|
} else if (location == "texture") {
|
|
|
|
|
return DATA_LOCATION_TEXTURE;
|
|
|
|
|
} else if (location == "gpu-buffer") {
|
|
|
|
|
return DATA_LOCATION_GPU_BUFFER;
|
|
|
|
|
} else if (location == "ml-tensor") {
|
|
|
|
|
return DATA_LOCATION_ML_TENSOR;
|
|
|
|
|
} else {
|
|
|
|
|
return DATA_LOCATION_NONE;
|
|
|
|
|
}
|
|
|
|
|
}
|