Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Tensor.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef DOM_TENSOR_H_
#define DOM_TENSOR_H_

#include "js/TypeDecls.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ONNXBinding.h"
#include "mozilla/dom/onnxruntime_c_api.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"

namespace mozilla::dom {
class Promise;

class Tensor final : public nsISupports, public nsWrapperCache {
 public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL
  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(Tensor)

 public:
  // Used when created from js using a regular js array, containing numbers.
  Tensor(const GlobalObject& global, const nsACString& type,
         const nsTArray<uint8_t>& data, const Sequence<int32_t>& dims);
  // Used when created from JS, e.g. input tensor, with a type array (it can be
  // of any type)
  Tensor(const GlobalObject& global, const nsACString& type,
         const ArrayBufferView& data, const Sequence<int32_t>& dims);
  // Used when created from C++, e.g. output tensor
  Tensor(const GlobalObject& aGlobal, ONNXTensorElementDataType aType,
         nsTArray<uint8_t> aData, nsTArray<int64_t> aDims);
  static already_AddRefed<Tensor> Constructor(
      const GlobalObject& global, const nsACString& type,
      const ArrayBufferViewOrAnySequence& data, const Sequence<int32_t>& dims,
      ErrorResult& aRv);

 protected:
  ~Tensor() = default;

 public:
  nsIGlobalObject* GetParentObject() const { return mGlobal; };
  JSObject* WrapObject(JSContext* aCx,
                       JS::Handle<JSObject*> aGivenProto) override;
  void GetDims(nsTArray<int32_t>& aRetVal);
  void SetDims(const nsTArray<int32_t>& aVal);
  void GetType(nsCString& aRetVal) const;
  void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal) const;
  TensorDataLocation Location() const;
  already_AddRefed<Promise> GetData(const Optional<bool>& releaseData);

  void Dispose();
  uint8_t* Data() { return mData.Elements(); }
  size_t Size() { return mData.Length(); }
  int32_t* Dims() { return mDims.Elements(); }
  size_t DimsSize() { return mDims.Length(); }

  ONNXTensorElementDataType Type() const;
  nsCString TypeString() const;
  nsLiteralCString ONNXTypeToString(ONNXTensorElementDataType aType) const;
  nsCString ToString() const;
  static ONNXTensorElementDataType StringToONNXDataType(
      const nsACString& aString);
  static size_t DataTypeSize(ONNXTensorElementDataType aType);

 private:
  nsCOMPtr<nsIGlobalObject> mGlobal;
  nsCString mType;
  nsTArray<uint8_t> mData;
  nsTArray<int32_t> mDims;
};

}  // namespace mozilla::dom

#endif  // DOM_TENSOR_H_

Messung V0.5 in Prozent
C=94 H=100 G=96

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=738142