Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM ONNX.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_ONNXBINDING_H_
#define DOM_ONNXBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Span.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/Record.h"
#include "mozilla/dom/RootedSequence.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/UnionMember.h"
namespace mozilla {
namespace dom {
class InferenceSession;
struct InferenceSessionRunOptionsAtoms;
struct InferenceSessionSessionOptionsAtoms;
struct NativePropertyHooks;
class OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord;
class ProtoAndIfaceCache;
class Tensor;
class TensorDataLocationOrUTF8StringTensorDataLocationRecord;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class TensorDataLocation : uint8_t {
None,
Cpu,
Cpu_pinned,
Texture,
Gpu_buffer,
Ml_tensor,
};
namespace binding_detail {
template <> struct EnumStrings<TensorDataLocation> {
static constexpr nsLiteralCString Values[6] {
"none"_ns,
"cpu"_ns,
"cpu-pinned"_ns,
"texture"_ns,
"gpu-buffer"_ns,
"ml-tensor"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, TensorDataLocation aArgument, JS::MutableHandle<JS::Value> aValue);
class ArrayBufferViewOrAnySequence : public AllUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<ArrayBufferViewOrAnySequence, true, ArrayBufferView>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eAnySequence
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eAnySequence = TypeOrUninit::eAnySequence
};
private:
union Value
{
UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView;
UnionMember<binding_detail::RootedAutoSequence<JS::Value> > mAnySequence;
};
TypeOrUninit mType;
Value mValue;
ArrayBufferViewOrAnySequence(const ArrayBufferViewOrAnySequence&) = delete;
ArrayBufferViewOrAnySequence& operator=(const ArrayBufferViewOrAnySequence&) = delete;
public:
explicit inline ArrayBufferViewOrAnySequence()
: mType(eUninitialized)
{
}
inline ~ArrayBufferViewOrAnySequence()
{
Uninit();
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
RawSetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
[[nodiscard]] inline RootedSpiderMonkeyInterface<ArrayBufferView>&
SetAsArrayBufferView(JSContext* cx)
{
if (mType == eArrayBufferView) {
return mValue.mArrayBufferView.Value();
}
Uninit();
mType = eArrayBufferView;
return mValue.mArrayBufferView.SetValue(cx);
}
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline RootedSpiderMonkeyInterface<ArrayBufferView>&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] inline binding_detail::RootedAutoSequence<JS::Value>&
RawSetAsAnySequence(JSContext* cx)
{
if (mType == eAnySequence) {
return mValue.mAnySequence.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eAnySequence;
return mValue.mAnySequence.SetValue(cx);
}
[[nodiscard]] inline binding_detail::RootedAutoSequence<JS::Value>&
SetAsAnySequence(JSContext* cx)
{
if (mType == eAnySequence) {
return mValue.mAnySequence.Value();
}
Uninit();
mType = eAnySequence;
return mValue.mAnySequence.SetValue(cx);
}
inline bool
IsAnySequence() const
{
return mType == eAnySequence;
}
inline binding_detail::RootedAutoSequence<JS::Value>&
GetAsAnySequence()
{
MOZ_RELEASE_ASSERT(IsAnySequence(), "Wrong type!");
return mValue.mAnySequence.Value();
}
inline const Sequence<JS::Value>&
GetAsAnySequence() const
{
MOZ_RELEASE_ASSERT(IsAnySequence(), "Wrong type!");
return mValue.mAnySequence.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eArrayBufferView: {
DestroyArrayBufferView();
break;
}
case eAnySequence: {
DestroyAnySequence();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
mValue.mArrayBufferView.Destroy();
mType = eUninitialized;
}
bool
TrySetToAnySequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToAnySequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyAnySequence()
{
MOZ_RELEASE_ASSERT(IsAnySequence(), "Wrong type!");
mValue.mAnySequence.Destroy();
mType = eUninitialized;
}
};
class OwningArrayBufferViewOrAnySequence : public AllOwningUnionBase,
public UnionWithTypedArraysBase
{
public:
using ApplyToTypedArrays = binding_detail::ApplyToTypedArraysHelper<OwningArrayBufferViewOrAnySequence, true, ArrayBufferView>;
private:
enum TypeOrUninit
{
eUninitialized,
eArrayBufferView,
eAnySequence
};
public:
enum class Type
{
eArrayBufferView = TypeOrUninit::eArrayBufferView,
eAnySequence = TypeOrUninit::eAnySequence
};
private:
union Value
{
UnionMember<ArrayBufferView > mArrayBufferView;
UnionMember<Sequence<JS::Value> > mAnySequence;
};
TypeOrUninit mType;
Value mValue;
OwningArrayBufferViewOrAnySequence(const OwningArrayBufferViewOrAnySequence&) = delete;
OwningArrayBufferViewOrAnySequence& operator=(const OwningArrayBufferViewOrAnySequence&) = delete;
public:
explicit inline OwningArrayBufferViewOrAnySequence()
: mType(eUninitialized)
{
}
OwningArrayBufferViewOrAnySequence(OwningArrayBufferViewOrAnySequence&& aOther);
inline ~OwningArrayBufferViewOrAnySequence()
{
Uninit();
}
[[nodiscard]] ArrayBufferView&
RawSetAsArrayBufferView();
[[nodiscard]] ArrayBufferView&
SetAsArrayBufferView();
inline bool
IsArrayBufferView() const
{
return mType == eArrayBufferView;
}
inline ArrayBufferView&
GetAsArrayBufferView()
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
inline ArrayBufferView const &
GetAsArrayBufferView() const
{
MOZ_RELEASE_ASSERT(IsArrayBufferView(), "Wrong type!");
return mValue.mArrayBufferView.Value();
}
[[nodiscard]] Sequence<JS::Value>&
RawSetAsAnySequence();
[[nodiscard]] Sequence<JS::Value>&
SetAsAnySequence();
inline bool
IsAnySequence() const
{
return mType == eAnySequence;
}
inline Sequence<JS::Value>&
GetAsAnySequence()
{
MOZ_RELEASE_ASSERT(IsAnySequence(), "Wrong type!");
return mValue.mAnySequence.Value();
}
inline Sequence<JS::Value> const &
GetAsAnySequence() const
{
MOZ_RELEASE_ASSERT(IsAnySequence(), "Wrong type!");
return mValue.mAnySequence.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
void
TraceUnion(JSTracer* trc);
OwningArrayBufferViewOrAnySequence&
operator=(OwningArrayBufferViewOrAnySequence&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToArrayBufferView(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToArrayBufferView(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyArrayBufferView();
bool
TrySetToAnySequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToAnySequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyAnySequence();
};
struct InferenceSessionRunOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR uint16_t mLogSeverityLevel;
MOZ_INIT_OUTSIDE_CTOR uint32_t mLogVerbosityLevel;
MOZ_INIT_OUTSIDE_CTOR nsCString mTag;
MOZ_INIT_OUTSIDE_CTOR bool mTerminate;
InferenceSessionRunOptions();
explicit inline InferenceSessionRunOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
InferenceSessionRunOptions(InferenceSessionRunOptions&& aOther) = default;
explicit inline InferenceSessionRunOptions(const InferenceSessionRunOptions& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
InferenceSessionRunOptions&
operator=(const InferenceSessionRunOptions& aOther);
private:
static bool
InitIds(JSContext* cx, InferenceSessionRunOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastInferenceSessionRunOptions : public InferenceSessionRunOptions
{
inline FastInferenceSessionRunOptions()
: InferenceSessionRunOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class TensorDataLocationOrUTF8StringTensorDataLocationRecord : public AllUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eTensorDataLocation,
eUTF8StringTensorDataLocationRecord
};
public:
enum class Type
{
eTensorDataLocation = TypeOrUninit::eTensorDataLocation,
eUTF8StringTensorDataLocationRecord = TypeOrUninit::eUTF8StringTensorDataLocationRecord
};
private:
union Value
{
UnionMember<TensorDataLocation > mTensorDataLocation;
UnionMember<Record<nsCString, TensorDataLocation> > mUTF8StringTensorDataLocationRecord;
};
TypeOrUninit mType;
Value mValue;
TensorDataLocationOrUTF8StringTensorDataLocationRecord(const TensorDataLocationOrUTF8StringTensorDataLocationRecord&) = delete;
TensorDataLocationOrUTF8StringTensorDataLocationRecord& operator=(const TensorDataLocationOrUTF8StringTensorDataLocationRecord&) = delete;
public:
explicit inline TensorDataLocationOrUTF8StringTensorDataLocationRecord()
: mType(eUninitialized)
{
}
inline ~TensorDataLocationOrUTF8StringTensorDataLocationRecord()
{
Uninit();
}
[[nodiscard]] inline TensorDataLocation&
RawSetAsTensorDataLocation()
{
if (mType == eTensorDataLocation) {
return mValue.mTensorDataLocation.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eTensorDataLocation;
return mValue.mTensorDataLocation.SetValue();
}
[[nodiscard]] inline TensorDataLocation&
SetAsTensorDataLocation()
{
if (mType == eTensorDataLocation) {
return mValue.mTensorDataLocation.Value();
}
Uninit();
mType = eTensorDataLocation;
return mValue.mTensorDataLocation.SetValue();
}
inline bool
IsTensorDataLocation() const
{
return mType == eTensorDataLocation;
}
inline TensorDataLocation&
GetAsTensorDataLocation()
{
MOZ_RELEASE_ASSERT(IsTensorDataLocation(), "Wrong type!");
return mValue.mTensorDataLocation.Value();
}
inline TensorDataLocation
GetAsTensorDataLocation() const
{
MOZ_RELEASE_ASSERT(IsTensorDataLocation(), "Wrong type!");
return mValue.mTensorDataLocation.Value();
}
[[nodiscard]] inline Record<nsCString, TensorDataLocation>&
RawSetAsUTF8StringTensorDataLocationRecord()
{
if (mType == eUTF8StringTensorDataLocationRecord) {
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUTF8StringTensorDataLocationRecord;
return mValue.mUTF8StringTensorDataLocationRecord.SetValue();
}
[[nodiscard]] inline Record<nsCString, TensorDataLocation>&
SetAsUTF8StringTensorDataLocationRecord()
{
if (mType == eUTF8StringTensorDataLocationRecord) {
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
Uninit();
mType = eUTF8StringTensorDataLocationRecord;
return mValue.mUTF8StringTensorDataLocationRecord.SetValue();
}
inline bool
IsUTF8StringTensorDataLocationRecord() const
{
return mType == eUTF8StringTensorDataLocationRecord;
}
inline Record<nsCString, TensorDataLocation>&
GetAsUTF8StringTensorDataLocationRecord()
{
MOZ_RELEASE_ASSERT(IsUTF8StringTensorDataLocationRecord(), "Wrong type!");
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
inline const Record<nsCString, TensorDataLocation>&
GetAsUTF8StringTensorDataLocationRecord() const
{
MOZ_RELEASE_ASSERT(IsUTF8StringTensorDataLocationRecord(), "Wrong type!");
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
inline void
Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eTensorDataLocation: {
DestroyTensorDataLocation();
break;
}
case eUTF8StringTensorDataLocationRecord: {
DestroyUTF8StringTensorDataLocationRecord();
break;
}
}
}
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
private:
bool
TrySetToTensorDataLocation(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTensorDataLocation(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyTensorDataLocation()
{
MOZ_RELEASE_ASSERT(IsTensorDataLocation(), "Wrong type!");
mValue.mTensorDataLocation.Destroy();
mType = eUninitialized;
}
bool
TrySetToUTF8StringTensorDataLocationRecord(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUTF8StringTensorDataLocationRecord(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
inline void
DestroyUTF8StringTensorDataLocationRecord()
{
MOZ_RELEASE_ASSERT(IsUTF8StringTensorDataLocationRecord(), "Wrong type!");
mValue.mUTF8StringTensorDataLocationRecord.Destroy();
mType = eUninitialized;
}
};
class OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord : public AllOwningUnionBase
{
enum TypeOrUninit
{
eUninitialized,
eTensorDataLocation,
eUTF8StringTensorDataLocationRecord
};
public:
enum class Type
{
eTensorDataLocation = TypeOrUninit::eTensorDataLocation,
eUTF8StringTensorDataLocationRecord = TypeOrUninit::eUTF8StringTensorDataLocationRecord
};
private:
union Value
{
UnionMember<TensorDataLocation > mTensorDataLocation;
UnionMember<Record<nsCString, TensorDataLocation> > mUTF8StringTensorDataLocationRecord;
};
TypeOrUninit mType;
Value mValue;
OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord(const OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord&) = delete;
OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord& operator=(const OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord&) = delete;
public:
explicit inline OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord()
: mType(eUninitialized)
{
}
OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord(OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord&& aOther);
inline ~OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord()
{
Uninit();
}
[[nodiscard]] TensorDataLocation&
RawSetAsTensorDataLocation();
[[nodiscard]] TensorDataLocation&
SetAsTensorDataLocation();
inline bool
IsTensorDataLocation() const
{
return mType == eTensorDataLocation;
}
inline TensorDataLocation&
GetAsTensorDataLocation()
{
MOZ_RELEASE_ASSERT(IsTensorDataLocation(), "Wrong type!");
return mValue.mTensorDataLocation.Value();
}
inline TensorDataLocation const &
GetAsTensorDataLocation() const
{
MOZ_RELEASE_ASSERT(IsTensorDataLocation(), "Wrong type!");
return mValue.mTensorDataLocation.Value();
}
[[nodiscard]] Record<nsCString, TensorDataLocation>&
RawSetAsUTF8StringTensorDataLocationRecord();
[[nodiscard]] Record<nsCString, TensorDataLocation>&
SetAsUTF8StringTensorDataLocationRecord();
inline bool
IsUTF8StringTensorDataLocationRecord() const
{
return mType == eUTF8StringTensorDataLocationRecord;
}
inline Record<nsCString, TensorDataLocation>&
GetAsUTF8StringTensorDataLocationRecord()
{
MOZ_RELEASE_ASSERT(IsUTF8StringTensorDataLocationRecord(), "Wrong type!");
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
inline Record<nsCString, TensorDataLocation> const &
GetAsUTF8StringTensorDataLocationRecord() const
{
MOZ_RELEASE_ASSERT(IsUTF8StringTensorDataLocationRecord(), "Wrong type!");
return mValue.mUTF8StringTensorDataLocationRecord.Value();
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
Uninit();
bool
ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord&
operator=(OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord&& aOther);
inline Type
GetType() const
{
MOZ_RELEASE_ASSERT(mType != eUninitialized);
return static_cast<Type>(mType);
}
private:
bool
TrySetToTensorDataLocation(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToTensorDataLocation(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyTensorDataLocation();
bool
TrySetToUTF8StringTensorDataLocationRecord(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
bool
TrySetToUTF8StringTensorDataLocationRecord(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
void
DestroyUTF8StringTensorDataLocationRecord();
};
struct InferenceSessionSessionOptions : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR bool mEnableCpuMemArena;
MOZ_INIT_OUTSIDE_CTOR bool mEnableGraphCapture;
MOZ_INIT_OUTSIDE_CTOR bool mEnableMemPattern;
MOZ_INIT_OUTSIDE_CTOR bool mEnableProfiling;
MOZ_INIT_OUTSIDE_CTOR nsCString mExecutionMode;
MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<JS::Value>> mExecutionProviders;
MOZ_INIT_OUTSIDE_CTOR Optional<Record<nsCString, JS::Value>> mExtra;
MOZ_INIT_OUTSIDE_CTOR Optional<Record<nsCString, uint32_t>> mFreeDimensionOverrides;
MOZ_INIT_OUTSIDE_CTOR nsCString mGraphOptimizationLevel;
MOZ_INIT_OUTSIDE_CTOR uint32_t mInterOpNumThreads;
MOZ_INIT_OUTSIDE_CTOR uint32_t mIntraOpNumThreads;
MOZ_INIT_OUTSIDE_CTOR nsCString mLogId;
MOZ_INIT_OUTSIDE_CTOR uint16_t mLogSeverityLevel;
MOZ_INIT_OUTSIDE_CTOR uint32_t mLogVerbosityLevel;
MOZ_INIT_OUTSIDE_CTOR nsCString mOptimizedModelFilePath;
MOZ_INIT_OUTSIDE_CTOR Optional<OwningTensorDataLocationOrUTF8StringTensorDataLocationRecord> mPreferredOutputLocation;
MOZ_INIT_OUTSIDE_CTOR nsCString mProfileFilePrefix;
InferenceSessionSessionOptions();
explicit inline InferenceSessionSessionOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
InferenceSessionSessionOptions(InferenceSessionSessionOptions&& aOther) = default;
private:
InferenceSessionSessionOptions(const InferenceSessionSessionOptions&) = delete;
InferenceSessionSessionOptions& operator=(const InferenceSessionSessionOptions&) = delete;
static bool
InitIds(JSContext* cx, InferenceSessionSessionOptionsAtoms* atomsCache);
public:
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastInferenceSessionSessionOptions : public InferenceSessionSessionOptions
{
inline FastInferenceSessionSessionOptions()
: InferenceSessionSessionOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace InferenceSession_Binding {
typedef mozilla::dom::InferenceSession NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::InferenceSession* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
ClearCachedInputNamesValue(mozilla::dom::InferenceSession* aObject);
void
ClearCachedOutputNamesValue(mozilla::dom::InferenceSession* aObject);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::InferenceSession,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace InferenceSession_Binding
namespace Tensor_Binding {
typedef mozilla::dom::Tensor NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::Tensor* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
ClearCachedDimsValue(mozilla::dom::Tensor* aObject);
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::Tensor,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace Tensor_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::TensorDataLocation>
{
static constexpr dom::TensorDataLocation value = dom::TensorDataLocation::Ml_tensor;
static_assert(static_cast<uint8_t>(dom::TensorDataLocation::None) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::TensorDataLocation>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_ONNXBINDING_H_