2024-01-03 18:13:17 +00:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
import {env} from './env-impl.js';
|
|
|
|
|
|
[js/common] fix typedoc warnings (#19933)
### Description
Fix a few warnings in typedoc (for generating JS API):
```
[warning] The signature TrainingSession.loadParametersBuffer has an @param with name "buffer", which was not used.
[warning] NonTensorType, defined in ./lib/onnx-value.ts, is referenced by OnnxValue but not included in the documentation.
[warning] TensorFactory, defined in ./lib/tensor-factory.ts, is referenced by Tensor but not included in the documentation.
[warning] ExternalDataFileType, defined in ./lib/onnx-model.ts, is referenced by InferenceSession.SessionOptions.externalData but not included in the documentation.
[warning] TensorToDataUrlOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toDataURL.toDataURL.options but not included in the documentation.
[warning] TensorToImageDataOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toImageData.toImageData.options but not included in the documentation.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.adapter.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.device.
```
Changes highlighted:
- Merge `CoreMlExecutionProviderOption` and
`CoreMLExecutionProviderOption`. They expose 2 set of different options
for React-native and ORT nodejs binding. This should be fixed in future.
- Fix a few inconsistency of names between JSDoc and parameters
- Fix broken type links
- Exclude trace functions
2024-03-16 02:01:50 +00:00
|
|
|
/**
|
|
|
|
|
* @ignore
|
|
|
|
|
*/
|
2024-01-03 18:13:17 +00:00
|
|
|
export const TRACE = (deviceType: string, label: string) => {
|
2024-02-27 19:07:15 +00:00
|
|
|
if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
|
2024-01-03 18:13:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.timeStamp(`${deviceType}::ORT::${label}`);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TRACE_FUNC = (msg: string, extraMsg?: string) => {
|
|
|
|
|
const stack = new Error().stack?.split(/\r\n|\r|\n/g) || [];
|
|
|
|
|
let hasTraceFunc = false;
|
|
|
|
|
for (let i = 0; i < stack.length; i++) {
|
|
|
|
|
if (hasTraceFunc && !stack[i].includes('TRACE_FUNC')) {
|
|
|
|
|
let label = `FUNC_${msg}::${stack[i].trim().split(' ')[1]}`;
|
|
|
|
|
if (extraMsg) {
|
|
|
|
|
label += `::${extraMsg}`;
|
|
|
|
|
}
|
|
|
|
|
TRACE('CPU', label);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (stack[i].includes('TRACE_FUNC')) {
|
|
|
|
|
hasTraceFunc = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
[js/common] fix typedoc warnings (#19933)
### Description
Fix a few warnings in typedoc (for generating JS API):
```
[warning] The signature TrainingSession.loadParametersBuffer has an @param with name "buffer", which was not used.
[warning] NonTensorType, defined in ./lib/onnx-value.ts, is referenced by OnnxValue but not included in the documentation.
[warning] TensorFactory, defined in ./lib/tensor-factory.ts, is referenced by Tensor but not included in the documentation.
[warning] ExternalDataFileType, defined in ./lib/onnx-model.ts, is referenced by InferenceSession.SessionOptions.externalData but not included in the documentation.
[warning] TensorToDataUrlOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toDataURL.toDataURL.options but not included in the documentation.
[warning] TensorToImageDataOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toImageData.toImageData.options but not included in the documentation.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.adapter.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.device.
```
Changes highlighted:
- Merge `CoreMlExecutionProviderOption` and
`CoreMLExecutionProviderOption`. They expose 2 set of different options
for React-native and ORT nodejs binding. This should be fixed in future.
- Fix a few inconsistency of names between JSDoc and parameters
- Fix broken type links
- Exclude trace functions
2024-03-16 02:01:50 +00:00
|
|
|
/**
|
|
|
|
|
* @ignore
|
|
|
|
|
*/
|
2024-01-03 18:13:17 +00:00
|
|
|
export const TRACE_FUNC_BEGIN = (extraMsg?: string) => {
|
2024-02-27 19:07:15 +00:00
|
|
|
if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
|
2024-01-03 18:13:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TRACE_FUNC('BEGIN', extraMsg);
|
|
|
|
|
};
|
|
|
|
|
|
[js/common] fix typedoc warnings (#19933)
### Description
Fix a few warnings in typedoc (for generating JS API):
```
[warning] The signature TrainingSession.loadParametersBuffer has an @param with name "buffer", which was not used.
[warning] NonTensorType, defined in ./lib/onnx-value.ts, is referenced by OnnxValue but not included in the documentation.
[warning] TensorFactory, defined in ./lib/tensor-factory.ts, is referenced by Tensor but not included in the documentation.
[warning] ExternalDataFileType, defined in ./lib/onnx-model.ts, is referenced by InferenceSession.SessionOptions.externalData but not included in the documentation.
[warning] TensorToDataUrlOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toDataURL.toDataURL.options but not included in the documentation.
[warning] TensorToImageDataOptions, defined in ./lib/tensor-conversion.ts, is referenced by Tensor.toImageData.toImageData.options but not included in the documentation.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.adapter.
[warning] Failed to resolve link to "GpuBufferType" in comment for Env.WebGpuFlags.device.
```
Changes highlighted:
- Merge `CoreMlExecutionProviderOption` and
`CoreMLExecutionProviderOption`. They expose 2 set of different options
for React-native and ORT nodejs binding. This should be fixed in future.
- Fix a few inconsistency of names between JSDoc and parameters
- Fix broken type links
- Exclude trace functions
2024-03-16 02:01:50 +00:00
|
|
|
/**
|
|
|
|
|
* @ignore
|
|
|
|
|
*/
|
2024-01-03 18:13:17 +00:00
|
|
|
export const TRACE_FUNC_END = (extraMsg?: string) => {
|
2024-02-27 19:07:15 +00:00
|
|
|
if (typeof env.trace === 'undefined' ? !env.wasm.trace : !env.trace) {
|
2024-01-03 18:13:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TRACE_FUNC('END', extraMsg);
|
|
|
|
|
};
|