• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit MindSporeLiteKit
19 */
20
21import { Callback } from './@ohos.base';
22
23/**
24 * @namespace mindSporeLite
25 * @syscap SystemCapability.AI.MindSporeLite
26 * @stagemodelonly
27 * @since 10
28 */
29declare namespace mindSporeLite {
30  /**
31   * Create a Model instance from file path
32   * @param { string } model - model indicates model path to be loaded
33   * @param { Context } context - context indicates model context information
34   * @returns { Promise<Model> } the promise returned by the function.
35   * @syscap SystemCapability.AI.MindSporeLite
36   * @stagemodelonly
37   * @since 10
38   */
39  function loadModelFromFile(
40    model: string,
41    context?: Context): Promise<Model>;
42
43  /**
44   * Create a Model instance from file path.
45   * @param { string } model - model indicates model path to be loaded
46   * @param { Callback<Model> } callback - the callback of model
47   * @syscap SystemCapability.AI.MindSporeLite
48   * @stagemodelonly
49   * @since 10
50   */
51  function loadModelFromFile(
52    model: string, callback: Callback<Model>): void;
53
54  /**
55   * Create a Model instance from file path.
56   * @param { string } model - model indicates model path to be loaded
57   * @param { Context } context - context indicates model context information
58   * @param { Callback<Model> } callback - the callback of model
59   * @syscap SystemCapability.AI.MindSporeLite
60   * @stagemodelonly
61   * @since 10
62   */
63  function loadModelFromFile(
64    model: string,
65    context: Context, callback: Callback<Model>): void;
66
67  /**
68   * Create a Model instance from buffer
69   * @param { ArrayBuffer } model - model indicates model buffer to be loaded
70   * @param { Context } [context] - context indicates model context information
71   * @returns { Promise<Model> } the promise returned by the function.
72   * @syscap SystemCapability.AI.MindSporeLite
73   * @stagemodelonly
74   * @since 10
75   */
76  function loadModelFromBuffer(
77    model: ArrayBuffer,
78    context?: Context): Promise<Model>;
79
80  /**
81   * Create a Model instance from buffer
82   * @param { ArrayBuffer } model - model indicates model buffer to be loaded
83   * @param { Callback<Model> } callback - the callback of model
84   * @syscap SystemCapability.AI.MindSporeLite
85   * @stagemodelonly
86   * @since 10
87   */
88  function loadModelFromBuffer(
89    model: ArrayBuffer, callback: Callback<Model>): void;
90
91  /**
92   * Create a Model instance from buffer
93   * @param { ArrayBuffer } model - model indicates model buffer to be loaded
94   * @param { Context } context - context indicates model context information
95   * @param { Callback<Model> } callback - the callback of model
96   * @syscap SystemCapability.AI.MindSporeLite
97   * @stagemodelonly
98   * @since 10
99   */
100  function loadModelFromBuffer(
101    model: ArrayBuffer,
102    context: Context, callback: Callback<Model>): void;
103
104  /**
105   * Creates a Model instance file description
106   * @param { number } model - model indicates model file description to be loaded
107   * @param { Context } [context] - context indicates model context information
108   * @returns { Promise<Model> } the promise returned by the function.
109   * @syscap SystemCapability.AI.MindSporeLite
110   * @stagemodelonly
111   * @since 10
112   */
113  function loadModelFromFd(
114    model: number,
115    context?: Context): Promise<Model>;
116
117  /**
118   * Create a Model instance from file description
119   * @param { number } model - model indicates model file description to be loaded
120   * @param { Callback<Model> } callback - the callback of model
121   * @syscap SystemCapability.AI.MindSporeLite
122   * @stagemodelonly
123   * @since 10
124   */
125  function loadModelFromFd(
126    model: number, callback: Callback<Model>): void;
127
128  /**
129   * Create a Model instance from file description
130   * @param { number } model - model indicates model file description to be loaded
131   * @param { Context } context - context indicates model context information
132   * @param { Callback<Model> } callback - the callback of model
133   * @syscap SystemCapability.AI.MindSporeLite
134   * @stagemodelonly
135   * @since 10
136   */
137  function loadModelFromFd(
138    model: number,
139    context: Context, callback: Callback<Model>): void;
140
141  /**
142   * Load train model from file
143   * @param { string } model - model file path
144   * @param { TrainCfg } [trainCfg] - model train configuration
145   * @param { Context } [context] - model build context
146   * @returns { Promise<Model> } the promise of the built model
147   * @syscap SystemCapability.AI.MindSporeLite
148   * @stagemodelonly
149   * @since 12
150   */
151  function loadTrainModelFromFile(
152    model: string,
153    trainCfg?: TrainCfg,
154    context?: Context): Promise<Model>;
155
156  /**
157   * Load train model from buffer
158   * @param { ArrayBuffer } model - model buffer
159   * @param { TrainCfg } [trainCfg] - model train configuration
160   * @param { Context } [context] - model build context
161   * @returns { Promise<Model> } the promise of the built model
162   * @syscap SystemCapability.AI.MindSporeLite
163   * @stagemodelonly
164   * @since 12
165   */
166  function loadTrainModelFromBuffer(
167    model: ArrayBuffer,
168    trainCfg?: TrainCfg,
169    context?: Context): Promise<Model>;
170
171  /**
172   * Load train model from file description
173   * @param { number } model - model file description
174   * @param { TrainCfg } [trainCfg] - model train configuration
175   * @param { Context } [context] - model build context
176   * @returns { Promise<Model> } the promise of the built model
177   * @syscap SystemCapability.AI.MindSporeLite
178   * @stagemodelonly
179   * @since 12
180   */
181  function loadTrainModelFromFd(
182    model: number,
183    trainCfg?: TrainCfg,
184    context?: Context): Promise<Model>;
185
186  /**
187   * Provides manages model function. Including get inputs, predict ,resize.
188   * @typedef Model
189   * @syscap SystemCapability.AI.MindSporeLite
190   * @stagemodelonly
191   * @since 10
192   */
193  interface Model {
194    /**
195     * The learning rate of the training model
196     * @type {?number}
197     * @syscap SystemCapability.AI.MindSporeLite
198     * @stagemodelonly
199     * @since 12
200     */
201    learningRate?: number;
202
203    /**
204     * The running mode of the model
205     * @type {?boolean}
206     * @syscap SystemCapability.AI.MindSporeLite
207     * @stagemodelonly
208     * @since 12
209     */
210    trainMode?: boolean;
211
212    /**
213     * Get model input tensors.
214     * @returns { MSTensor[] } the MSTensor array of the inputs.
215     * @syscap SystemCapability.AI.MindSporeLite
216     * @stagemodelonly
217     * @since 10
218     */
219    getInputs(): MSTensor[];
220
221    /**
222     * Infer model
223     * @param { MSTensor[] } inputs - indicates the MSTensor array of the inputs.
224     * @param { Callback<MSTensor[]> }  callback - the callback of MSTensor array.
225     * @syscap SystemCapability.AI.MindSporeLite
226     * @stagemodelonly
227     * @since 10
228     */
229    predict(inputs: MSTensor[], callback: Callback<MSTensor[]>): void;
230
231    /**
232     * Infer model
233     * @param { MSTensor[] } inputs - indicates the MSTensor array of the inputs.
234     * @returns { Promise<MSTensor[]> } the promise returned by the function.
235     * @syscap SystemCapability.AI.MindSporeLite
236     * @stagemodelonly
237     * @since 10
238     */
239    predict(inputs: MSTensor[]): Promise<MSTensor[]>;
240
241    /**
242     * resize model input
243     * @param { MSTensor[] } inputs - indicates the MSTensor array of the inputs.
244     * @param { Array<Array<number>> } dims - indicates the target new shape array
245     * @returns { boolean } the boolean result if the resize operation is successful
246     * @syscap SystemCapability.AI.MindSporeLite
247     * @stagemodelonly
248     * @since 10
249     */
250    resize(inputs: MSTensor[], dims: Array<Array<number>>): boolean;
251
252    /**
253     * Train model by step
254     * @param { MSTensor[] } inputs - indicates the MSTensor array of the inputs.
255     * @returns { boolean } the boolean result if the runStep operation is successful
256     * @syscap SystemCapability.AI.MindSporeLite
257     * @stagemodelonly
258     * @since 12
259     */
260    runStep(inputs: MSTensor[]): boolean;
261
262    /**
263     * Obtain all weights of the model
264     * @returns { MSTensor[] } the weight tensors of the model
265     * @syscap SystemCapability.AI.MindSporeLite
266     * @stagemodelonly
267     * @since 12
268     */
269    getWeights(): MSTensor[];
270
271    /**
272     * Update weights of the model
273     * @param { MSTensor[] } weights - indicates the MSTensor array of the inputs
274     * @returns { boolean } the boolean result if updating weights operation is successful
275     * @syscap SystemCapability.AI.MindSporeLite
276     * @stagemodelonly
277     * @since 12
278     */
279    updateWeights(weights: MSTensor[]): boolean;
280
281    /**
282     * Setup training with virtual batches
283     * @param { number } virtualBatchMultiplier - virtual batch multiplier, use any number < 1 to disable
284     * @param { number } lr - learning rate to use for virtual batch, -1 for internal configuration
285     * @param { number } momentum - batch norm momentum to use for virtual batch, -1 for internal configuration
286     * @returns { boolean } the boolean result if the operation is successful
287     * @syscap SystemCapability.AI.MindSporeLite
288     * @stagemodelonly
289     * @since 12
290     */
291    setupVirtualBatch(virtualBatchMultiplier: number, lr: number, momentum: number): boolean;
292
293    /**
294     * Export train model to file
295     * @param { string } modelFile - model file path.
296     * @param { QuantizationType } [quantizationType] - the quantization type, default NO_QUANT.
297     * @param { boolean } [exportInferenceOnly] - whether to export a inference only model, default true.
298     * @param { string[] } [outputTensorName] - the set of name of output tensor the exported inference model,
299     * @returns { boolean } - the boolean result if the operation is successful
300     * @syscap SystemCapability.AI.MindSporeLite
301     * @stagemodelonly
302     * @since 12
303     */
304    exportModel(
305      modelFile: string,
306      quantizationType?: QuantizationType,
307      exportInferenceOnly?: boolean,
308      outputTensorName?: string[]): boolean;
309
310    /**
311     * Export model's weights, which can be used in micro only. Only valid for Lite Train
312     * @param { string } weightFile - weight file path
313     * @param { boolean } [isInference] - whether to export weights from inference model, only support this is `true` for now, default true
314     * @param { boolean } [enableFp16] - float-weight is whether to be saved in float16 format, default false
315     * @param { string[] } [changeableWeightsName] - changeable weights name
316     * @returns { boolean } the boolean result if the operation is successful
317     * @syscap SystemCapability.AI.MindSporeLite
318     * @stagemodelonly
319     * @since 12
320     */
321    exportWeightsCollaborateWithMicro(
322      weightFile: string,
323      isInference?: boolean,
324      enableFp16?: boolean,
325      changeableWeightsName?: string[]): boolean;
326  }
327
328  /**
329   * Enum for quantization type
330   * @enum {number}
331   * @syscap SystemCapability.AI.MindSporeLite
332   * @stagemodelonly
333   * @since 12
334   */
335  export enum QuantizationType {
336    /**
337     * No quantization.
338     * @syscap SystemCapability.AI.MindSporeLite
339     * @stagemodelonly
340     * @since 12
341     */
342    NO_QUANT = 0,
343    /**
344     * Weight quantization.
345     * @syscap SystemCapability.AI.MindSporeLite
346     * @stagemodelonly
347     * @since 12
348     */
349    WEIGHT_QUANT = 1,
350    /**
351     * Full quantization.
352     * @syscap SystemCapability.AI.MindSporeLite
353     * @stagemodelonly
354     * @since 12
355     */
356    FULL_QUANT = 2,
357  }
358  /**
359   * Enum for optimization level
360   * @enum {number}
361   * @syscap SystemCapability.AI.MindSporeLite
362   * @stagemodelonly
363   * @since 12
364   */
365  export enum OptimizationLevel {
366    /**
367     * Do not change
368     * @syscap SystemCapability.AI.MindSporeLite
369     * @stagemodelonly
370     * @since 12
371     */
372    O0 = 0,
373    /**
374     * Cast network to float16, keep batch norm and loss in float32
375     * @syscap SystemCapability.AI.MindSporeLite
376     * @stagemodelonly
377     * @since 12
378     */
379    O2 = 2,
380    /**
381     * Cast network to float16, including batch norm
382     * @syscap SystemCapability.AI.MindSporeLite
383     * @stagemodelonly
384     * @since 12
385     */
386    O3 = 3,
387    /**
388     * Choose optimization based on device
389     * @syscap SystemCapability.AI.MindSporeLite
390     * @stagemodelonly
391     * @since 12
392     */
393    AUTO = 4,
394  }
395
396  /**
397   * Provides the train configuration
398   * @typedef TrainCfg
399   * @syscap SystemCapability.AI.MindSporeLite
400   * @stagemodelonly
401   * @since 12
402   */
403  interface TrainCfg {
404    /**
405     * Array of loss name
406     * @type {?string[]}
407     * @syscap SystemCapability.AI.MindSporeLite
408     * @stagemodelonly
409     * @since 12
410     */
411    lossName?: string[],
412    /**
413     * Train optimization level
414     * @type {?OptimizationLevel}
415     * @syscap SystemCapability.AI.MindSporeLite
416     * @stagemodelonly
417     * @since 12
418     */
419    optimizationLevel?: OptimizationLevel,
420  }
421
422  /**
423   * Provides the device configurations
424   * @typedef Context
425   * @syscap SystemCapability.AI.MindSporeLite
426   * @stagemodelonly
427   * @since 10
428   */
429  interface Context {
430    /**
431     * The target device
432     * @type {?string[]}
433     * @syscap SystemCapability.AI.MindSporeLite
434     * @stagemodelonly
435     * @since 10
436     */
437    target?: string[];
438    /**
439     * The cpu device information
440     * @type {?CpuDevice}
441     * @syscap SystemCapability.AI.MindSporeLite
442     * @stagemodelonly
443     * @since 10
444     */
445    cpu?: CpuDevice;
446    /**
447     * The NNRT device information
448     * @type {?NNRTDevice}
449     * @syscap SystemCapability.AI.MindSporeLite
450     * @stagemodelonly
451     * @since 10
452     */
453    nnrt?: NNRTDevice;
454  }
455
456  /**
457   * Provides the CPU device info
458   * @typedef CpuDevice
459   * @syscap SystemCapability.AI.MindSporeLite
460   * @stagemodelonly
461   * @since 10
462   */
463  interface CpuDevice {
464    /**
465     * The thread num
466     * @type {?number}
467     * @syscap SystemCapability.AI.MindSporeLite
468     * @stagemodelonly
469     * @since 10
470     */
471    threadNum?: number;
472    /**
473     * The thread affinity mode
474     * @type {?ThreadAffinityMode}
475     * @syscap SystemCapability.AI.MindSporeLite
476     * @stagemodelonly
477     * @since 10
478     */
479    threadAffinityMode?: ThreadAffinityMode;
480    /**
481     * The thread affinity core list
482     * @type {?number[]}
483     * @syscap SystemCapability.AI.MindSporeLite
484     * @stagemodelonly
485     * @since 10
486     */
487    threadAffinityCoreList?: number[];
488    /**
489     * The precision mode
490     * @type {?string}
491     * @syscap SystemCapability.AI.MindSporeLite
492     * @stagemodelonly
493     * @since 10
494     */
495    precisionMode?: string;
496  }
497
498  /**
499   * Enum for performance mode
500   * @enum {number}
501   * @syscap SystemCapability.AI.MindSporeLite
502   * @stagemodelonly
503   * @since 12
504   */
505  export enum PerformanceMode {
506    /**
507     * No performance mode preference
508     * @syscap SystemCapability.AI.MindSporeLite
509     * @stagemodelonly
510     * @since 12
511     */
512    PERFORMANCE_NONE = 0,
513    /**
514     * Low power consumption mode
515     * @syscap SystemCapability.AI.MindSporeLite
516     * @stagemodelonly
517     * @since 12
518     */
519    PERFORMANCE_LOW = 1,
520    /**
521     * Medium performance mode
522     * @syscap SystemCapability.AI.MindSporeLite
523     * @stagemodelonly
524     * @since 12
525     */
526    PERFORMANCE_MEDIUM = 2,
527    /**
528     * High performance mode
529     * @syscap SystemCapability.AI.MindSporeLite
530     * @stagemodelonly
531     * @since 12
532     */
533    PERFORMANCE_HIGH = 3,
534    /**
535     * Ultimate performance mode
536     * @syscap SystemCapability.AI.MindSporeLite
537     * @stagemodelonly
538     * @since 12
539     */
540    PERFORMANCE_EXTREME = 4,
541  }
542
543  /**
544   * Enum for scheduling priority
545   * @enum {number}
546   * @syscap SystemCapability.AI.MindSporeLite
547   * @stagemodelonly
548   * @since 12
549   */
550  export enum Priority {
551    /**
552     * No priority preference
553     * @syscap SystemCapability.AI.MindSporeLite
554     * @stagemodelonly
555     * @since 12
556     */
557    PRIORITY_NONE = 0,
558    /**
559     * Low priority
560     * @syscap SystemCapability.AI.MindSporeLite
561     * @stagemodelonly
562     * @since 12
563     */
564    PRIORITY_LOW = 1,
565    /**
566     * Medium priority
567     * @syscap SystemCapability.AI.MindSporeLite
568     * @stagemodelonly
569     * @since 12
570     */
571    PRIORITY_MEDIUM = 2,
572    /**
573     * High priority
574     * @syscap SystemCapability.AI.MindSporeLite
575     * @stagemodelonly
576     * @since 12
577     */
578    PRIORITY_HIGH = 3,
579  }
580
581  /**
582   * Provides the extension information of nnrt device
583   * @typedef Extension
584   * @syscap SystemCapability.AI.MindSporeLite
585   * @stagemodelonly
586   * @since 12
587   */
588  interface Extension {
589    /**
590     * Extension name
591     * @type {string}
592     * @syscap SystemCapability.AI.MindSporeLite
593     * @stagemodelonly
594     * @since 12
595     */
596    name: string,
597    /**
598     * Extension array buffer
599     * @type {ArrayBuffer}
600     * @syscap SystemCapability.AI.MindSporeLite
601     * @stagemodelonly
602     * @since 12
603     */
604    value: ArrayBuffer
605  }
606
607  /**
608   * Enum for nnrt device type
609   * @enum {number}
610   * @syscap SystemCapability.AI.MindSporeLite
611   * @stagemodelonly
612   * @since 12
613   */
614  export enum NNRTDeviceType {
615    /**
616     * Devices that are not CPU, GPU, or dedicated accelerator
617     * @syscap SystemCapability.AI.MindSporeLite
618     * @stagemodelonly
619     * @since 12
620     */
621    NNRTDEVICE_OTHERS = 0,
622
623    /**
624     * CPU device
625     * @syscap SystemCapability.AI.MindSporeLite
626     * @stagemodelonly
627     * @since 12
628     */
629    NNRTDEVICE_CPU = 1,
630
631    /**
632     * GPU device
633     * @syscap SystemCapability.AI.MindSporeLite
634     * @stagemodelonly
635     * @since 12
636     */
637    NNRTDEVICE_GPU = 2,
638
639    /**
640     * Dedicated hardware accelerator
641     * @syscap SystemCapability.AI.MindSporeLite
642     * @stagemodelonly
643     * @since 12
644     */
645    NNRTDEVICE_ACCELERATOR = 3,
646  }
647
648  /**
649   * Provides the nnrt device description
650   * @typedef NNRTDeviceDescription
651   * @syscap SystemCapability.AI.MindSporeLite
652   * @stagemodelonly
653   * @since 12
654   */
655  interface NNRTDeviceDescription {
656    /**
657     * Get device id
658     * @returns { bigint } the number of device id
659     * @syscap SystemCapability.AI.MindSporeLite
660     * @stagemodelonly
661     * @since 12
662     */
663    deviceID() : bigint;
664    /**
665     * Get device type.
666     * @returns { NNRTDeviceType } the device type
667     * @syscap SystemCapability.AI.MindSporeLite
668     * @stagemodelonly
669     * @since 12
670     */
671    deviceType() : NNRTDeviceType;
672    /**
673     * Get device name.
674     * @returns { string } device name
675     * @syscap SystemCapability.AI.MindSporeLite
676     * @stagemodelonly
677     * @since 12
678     */
679    deviceName() : string;
680  }
681
682  /**
683   * Obtain the all device descriptions in NNRT.
684   * @returns { NNRTDeviceDescription[] } the array of NNRTDeviceDescription
685   * @syscap SystemCapability.AI.MindSporeLite
686   * @stagemodelonly
687   * @since 12
688   */
689  function getAllNNRTDeviceDescriptions() : NNRTDeviceDescription[];
690
691  /**
692   * Provides the NNRT device info
693   * @typedef NNRTDevice
694   * @syscap SystemCapability.AI.MindSporeLite
695   * @stagemodelonly
696   * @since 10
697   */
698  interface NNRTDevice {
699    /**
700     * NNRT device id.
701     * @type {?bigint}
702     * @syscap SystemCapability.AI.MindSporeLite
703     * @stagemodelonly
704     * @since 12
705     */
706    deviceID?: bigint,
707    /**
708     * NNRT device performance mode.
709     * @type {?PerformanceMode}
710     * @syscap SystemCapability.AI.MindSporeLite
711     * @stagemodelonly
712     * @since 12
713     */
714    performanceMode?: PerformanceMode,
715    /**
716     * NNRT device priority.
717     * @type {?Priority}
718     * @syscap SystemCapability.AI.MindSporeLite
719     * @stagemodelonly
720     * @since 12
721     */
722    priority?: Priority,
723    /**
724     * NNRT device extension array.
725     * @type {?Extension[]}
726     * @syscap SystemCapability.AI.MindSporeLite
727     * @stagemodelonly
728     * @since 12
729     */
730    extensions?: Extension[],
731  }
732
733  /**
734   * Enum for provides CPU thread affinity mode
735   * @enum {number}
736   * @syscap SystemCapability.AI.MindSporeLite
737   * @stagemodelonly
738   * @since 10
739   */
740  export enum ThreadAffinityMode {
741    /**
742     * Thread affinity mode is no bind.
743     * @syscap SystemCapability.AI.MindSporeLite
744     * @stagemodelonly
745     * @since 10
746     */
747    NO_AFFINITIES = 0,
748
749    /**
750     * Thread affinity mode is big cores first
751     * @syscap SystemCapability.AI.MindSporeLite
752     * @stagemodelonly
753     * @since 10
754     */
755    BIG_CORES_FIRST = 1,
756
757    /**
758     * Thread affinity mode is little cores first
759     * @syscap SystemCapability.AI.MindSporeLite
760     * @stagemodelonly
761     * @since 10
762     */
763    LITTLE_CORES_FIRST = 2,
764  }
765
766  /**
767   * Provides MSTensor definition
768   * @typedef MSTensor
769   * @syscap SystemCapability.AI.MindSporeLite
770   * @stagemodelonly
771   * @since 10
772   */
773  interface MSTensor {
774    /**
775      * The name of the tensor.
776      * @type {string}
777      * @syscap SystemCapability.AI.MindSporeLite
778      * @stagemodelonly
779      * @since 10
780      */
781    name: string;
782    /**
783      * The shape of the tensor.
784      * @type {number[]}
785      * @syscap SystemCapability.AI.MindSporeLite
786      * @stagemodelonly
787      * @since 10
788      */
789    shape: number[];
790    /**
791      * The number of elements in the tensor.
792      * @type {number}
793      * @syscap SystemCapability.AI.MindSporeLite
794      * @stagemodelonly
795      * @since 10
796      */
797    elementNum: number;
798    /**
799      * The data size of the tensor.
800      * @type {number}
801      * @syscap SystemCapability.AI.MindSporeLite
802      * @stagemodelonly
803      * @since 10
804      */
805    dataSize: number;
806    /**
807      * The data type of the tensor.
808      * @type {DataType}
809      * @syscap SystemCapability.AI.MindSporeLite
810      * @stagemodelonly
811      * @since 10
812      */
813    dtype: DataType;
814    /**
815      * The format of the tensor.
816      * @type {Format}
817      * @syscap SystemCapability.AI.MindSporeLite
818      * @stagemodelonly
819      * @since 10
820      */
821    format: Format;
822
823    /**
824     * Get MSTensor data
825     * @returns { ArrayBuffer } the data of tensor
826     * @syscap SystemCapability.AI.MindSporeLite
827     * @stagemodelonly
828     * @since 10
829     */
830    getData(): ArrayBuffer;
831
832    /**
833     * Set MSTensor data
834     * @param { ArrayBuffer } inputArray - indicates the buffer of tensor
835     * @syscap SystemCapability.AI.MindSporeLite
836     * @stagemodelonly
837     * @since 10
838     */
839    setData(inputArray: ArrayBuffer): void;
840  }
841
842  /**
843   * Enum for provides MSTensor data type
844   * @enum {number}
845   * @syscap SystemCapability.AI.MindSporeLite
846   * @stagemodelonly
847   * @since 10
848   */
849  export enum DataType {
850    /**
851     * data type is unknown
852     * @syscap SystemCapability.AI.MindSporeLite
853     * @stagemodelonly
854     * @since 10
855     */
856    TYPE_UNKNOWN = 0,
857   /**
858     * data type is int8
859     * @syscap SystemCapability.AI.MindSporeLite
860     * @stagemodelonly
861     * @since 10
862     */
863    NUMBER_TYPE_INT8 = 32,
864   /**
865     * data type is int16
866     * @syscap SystemCapability.AI.MindSporeLite
867     * @stagemodelonly
868     * @since 10
869     */
870    NUMBER_TYPE_INT16 = 33,
871   /**
872     * data type is int32
873     * @syscap SystemCapability.AI.MindSporeLite
874     * @stagemodelonly
875     * @since 10
876     */
877    NUMBER_TYPE_INT32 = 34,
878   /**
879     * data type is int64
880     * @syscap SystemCapability.AI.MindSporeLite
881     * @stagemodelonly
882     * @since 10
883     */
884    NUMBER_TYPE_INT64 = 35,
885   /**
886     * data type is uint8
887     * @syscap SystemCapability.AI.MindSporeLite
888     * @stagemodelonly
889     * @since 10
890     */
891    NUMBER_TYPE_UINT8 = 37,
892   /**
893     * data type is uint16
894     * @syscap SystemCapability.AI.MindSporeLite
895     * @stagemodelonly
896     * @since 10
897     */
898    NUMBER_TYPE_UINT16 = 38,
899   /**
900     * data type is uint32
901     * @syscap SystemCapability.AI.MindSporeLite
902     * @stagemodelonly
903     * @since 10
904     */
905    NUMBER_TYPE_UINT32 = 39,
906   /**
907     * data type is uint64
908     * @syscap SystemCapability.AI.MindSporeLite
909     * @stagemodelonly
910     * @since 10
911     */
912    NUMBER_TYPE_UINT64 = 40,
913   /**
914     * data type is float16
915     * @syscap SystemCapability.AI.MindSporeLite
916     * @stagemodelonly
917     * @since 10
918     */
919    NUMBER_TYPE_FLOAT16 = 42,
920   /**
921     * data type is float32
922     * @syscap SystemCapability.AI.MindSporeLite
923     * @stagemodelonly
924     * @since 10
925     */
926    NUMBER_TYPE_FLOAT32 = 43,
927   /**
928     * data type is float64
929     * @syscap SystemCapability.AI.MindSporeLite
930     * @stagemodelonly
931     * @since 10
932     */
933    NUMBER_TYPE_FLOAT64 = 44,
934  }
935
936  /**
937   * Enum for provides MSTensor format
938   * @enum {number}
939   * @syscap SystemCapability.AI.MindSporeLite
940   * @stagemodelonly
941   * @since 10
942   */
943  export enum Format {
944   /**
945     * data format is default
946     * @syscap SystemCapability.AI.MindSporeLite
947     * @stagemodelonly
948     * @since 10
949     */
950    DEFAULT_FORMAT = -1,
951   /**
952     * data format is NCHW
953     * @syscap SystemCapability.AI.MindSporeLite
954     * @stagemodelonly
955     * @since 10
956     */
957    NCHW = 0,
958   /**
959     * data format is NHWC
960     * @syscap SystemCapability.AI.MindSporeLite
961     * @stagemodelonly
962     * @since 10
963     */
964    NHWC = 1,
965   /**
966     * data format is NHWC4
967     * @syscap SystemCapability.AI.MindSporeLite
968     * @stagemodelonly
969     * @since 10
970     */
971    NHWC4 = 2,
972   /**
973     * data format is HWKC
974     * @syscap SystemCapability.AI.MindSporeLite
975     * @stagemodelonly
976     * @since 10
977     */
978    HWKC = 3,
979   /**
980     * data format is HWCK
981     * @syscap SystemCapability.AI.MindSporeLite
982     * @stagemodelonly
983     * @since 10
984     */
985    HWCK = 4,
986   /**
987     * data format is KCHW
988     * @syscap SystemCapability.AI.MindSporeLite
989     * @stagemodelonly
990     * @since 10
991     */
992    KCHW = 5,
993  }
994}
995export default mindSporeLite;
996