Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tensor create method involves duplicate memory allocation operations #620

@wisper-shadow

Description

@wisper-shadow

Please make sure that this is a documentation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:doc_template

System information

  • TensorFlow version: 1.0
  • Doc Link:

according to this issue #258 using following code to create a high dim tensor

Yes, you need to convert your float array to a NdArray using the StdArrays utilities, before initializing a tensor with it, i.e.


TFloat32 t = TFloat32.tensorOf(StdArrays.ndCopyOf(floatImage));

Originally posted by @karllessard in #258

in StdArrays.ndCopyOf method, StdArrays will create a FloatNdArray and copy the origin 3 dim array to the NdArray, then in the TFloat32.tensorOf method, TFloat32 will finally call of(Class<T> type, Shape shape, long size) method and using RawTenor to allocate another memory area.

is this two allocation necessary, and why we need this two allocation?
or do we have any more optimized api to create a tensor with less memory allocation?

@Craigacp

Describe the documentation issue

We welcome contributions by users. Will you be able to update submit a PR (use the doc style guide) to fix the doc Issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions