Home / Function/ nativeNewTensor() — pytorch Function Reference

nativeNewTensor() — pytorch Function Reference

Architecture documentation for the nativeNewTensor() function in Tensor.java from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  41a84db6_8612_e249_8a37_5e6e3edc69db["nativeNewTensor()"]
  d0541c55_e071_388a_6fbc_230dd801b1c2["Tensor_float32()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| d0541c55_e071_388a_6fbc_230dd801b1c2
  35d622dc_2970_0523_b025_83c1944667cb["Tensor_int32()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| 35d622dc_2970_0523_b025_83c1944667cb
  9f59ba85_3436_012e_f41f_f63876497f15["Tensor_int64()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| 9f59ba85_3436_012e_f41f_f63876497f15
  5bc5322c_04dc_41b6_6e68_eb736b44a562["Tensor_float64()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| 5bc5322c_04dc_41b6_6e68_eb736b44a562
  ebc1f8d6_83ff_3cd6_75f5_92e4feb368ad["Tensor_uint8()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| ebc1f8d6_83ff_3cd6_75f5_92e4feb368ad
  460ea45b_83cb_3393_ffcc_537fe5f19147["Tensor_int8()"]
  41a84db6_8612_e249_8a37_5e6e3edc69db -->|calls| 460ea45b_83cb_3393_ffcc_537fe5f19147
  style 41a84db6_8612_e249_8a37_5e6e3edc69db fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

android/pytorch_android/src/main/java/org/pytorch/Tensor.java lines 705–734

  @DoNotStrip
  private static Tensor nativeNewTensor(
      ByteBuffer data, long[] shape, int dtype, int memoryFormatCode, HybridData hybridData) {
    Tensor tensor = null;

    MemoryFormat memoryFormat = MemoryFormat.CONTIGUOUS;
    if (MemoryFormat.CHANNELS_LAST.jniCode == memoryFormatCode) {
      memoryFormat = MemoryFormat.CHANNELS_LAST;
    } else if (MemoryFormat.CHANNELS_LAST_3D.jniCode == memoryFormatCode) {
      memoryFormat = MemoryFormat.CHANNELS_LAST_3D;
    }

    if (DType.FLOAT32.jniCode == dtype) {
      tensor = new Tensor_float32(data.asFloatBuffer(), shape, memoryFormat);
    } else if (DType.INT32.jniCode == dtype) {
      tensor = new Tensor_int32(data.asIntBuffer(), shape, memoryFormat);
    } else if (DType.INT64.jniCode == dtype) {
      tensor = new Tensor_int64(data.asLongBuffer(), shape, memoryFormat);
    } else if (DType.FLOAT64.jniCode == dtype) {
      tensor = new Tensor_float64(data.asDoubleBuffer(), shape, memoryFormat);
    } else if (DType.UINT8.jniCode == dtype) {
      tensor = new Tensor_uint8(data, shape, memoryFormat);
    } else if (DType.INT8.jniCode == dtype) {
      tensor = new Tensor_int8(data, shape, memoryFormat);
    } else {
      new IllegalArgumentException("Unknown Tensor dtype");
    }
    tensor.mHybridData = hybridData;
    return tensor;
  }

Subdomains

Frequently Asked Questions

What does nativeNewTensor() do?
nativeNewTensor() is a function in the pytorch codebase.
What does nativeNewTensor() call?
nativeNewTensor() calls 6 function(s): Tensor_float32, Tensor_float64, Tensor_int32, Tensor_int64, Tensor_int8, Tensor_uint8.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free