334 Star 1.5K Fork 863

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mstensor.md 4.36 KB
一键复制 编辑 原始数据 按行查看 历史
宦晓玲 提交于 2023-07-21 16:52 . modify the md links 1.8

MSTensor

View Source On Gitee

import com.mindspore.MSTensor;

MSTensor defined tensor in MindSpore.

Public Member Functions

function
MSTensor createTensor(String tensorName, int dataType, int[] tensorShape, ByteBuffer buffer)
int[] getShape()
int getDataType()
byte[] getByteData()
float[] getFloatData()
int[] getIntData()
long[] getLongData()
void setData(byte[] data)
void setData(float[] data)
void setData(ByteBuffer data)
long size()
int elementsNum()
void free()
String tensorName()
DataType

createTensor

public static MSTensor createTensor(String tensorName, int dataType, int[] tensorShape, ByteBuffer buffer)

Create MindSpore MSTensor.

  • Parameters

    • tensorName: tensor name.
    • dataType: tensor data type.
    • tensorShape: tensor shape.
    • buffer: tensor data buffer.
  • Returns

    MindSpore MSTensor.

getshape

public int[] getShape()

Get the shape of the MindSpore MSTensor.

  • Returns

    A array of int as the shape of the MindSpore MSTensor.

getDataType

public int getDataType()

DataType is defined in com.mindspore.DataType.

  • Returns

    The MindSpore data type of the MindSpore MSTensor class.

getByteData

public byte[] getByteData()

Get output data of MSTensor, the data type is byte.

  • Returns

    The byte array containing all MSTensor output data.

getFloatData

public float[] getFloatData()

Get output data of MSTensor, the data type is float.

  • Returns

    The float array containing all MSTensor output data.

getIntData

public int[] getIntData()

Get output data of MSTensor, the data type is int.

  • Returns

    The int array containing all MSTensor output data.

getLongData

public long[] getLongData()

Get output data of MSTensor, the data type is long.

  • Returns

    The long array containing all MSTensor output data.

setData

public void setData(byte[] data)

Set the input data of MSTensor.

  • Parameters

    • data: Input data of byte[] type.
public void setData(float[] data)

Set the input data of MSTensor.

  • Parameters

    • data: Input data of float[] type.
public void setData(ByteBuffer data)

Set the input data of MSTensor.

  • Parameters

    • data: Input data of ByteBuffer type.

size

public long size()

Get the size of the data in MSTensor in bytes.

  • Returns

    The size of the data in MSTensor in bytes.

elementsNum

public int elementsNum()

Get the number of elements in MSTensor.

  • Returns

    The number of elements in MSTensor.

free

public void free()

Free all temporary memory in MindSpore MSTensor.

tensorName

public String tensorName()

Get tensor name.

  • Returns

    Tensor name.

DataType

import com.mindspore.config.DataType;

Define tensor data type.

Public member variable

public static final int kNumberTypeBool = 30;
public static final int kNumberTypeInt = 31;
public static final int kNumberTypeInt8 = 32;
public static final int kNumberTypeInt16 = 33;
public static final int kNumberTypeInt32 = 34;
public static final int kNumberTypeInt64 = 35;
public static final int kNumberTypeUInt = 36;
public static final int kNumberTypeUInt8 = 37;
public static final int kNumberTypeUInt16 = 38;
public static final int kNumberTypeUint32 = 39;
public static final int kNumberTypeUInt64 = 40;
public static final int kNumberTypeFloat = 41;
public static final int kNumberTypeFloat16 = 42;
public static final int kNumberTypeFloat32 = 43;
public static final int kNumberTypeFloat64 = 44;
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r1.8

搜索帮助