Title: Tensor create method involves duplicate memory allocation operations · Issue #620 · tensorflow/java · GitHub
Open Graph Title: Tensor create method involves duplicate memory allocation operations · Issue #620 · tensorflow/java
X Title: Tensor create method involves duplicate memory allocation operations · Issue #620 · tensorflow/java
Description: 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 ve...
Open Graph Description: 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_t...
X Description: 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_t...
Opengraph URL: https://github.com/tensorflow/java/issues/620
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tensor create method involves duplicate memory allocation operations","articleBody":"\u003cem\u003ePlease make sure that this is a documentation issue. As per our [GitHub Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:doc_template\u003c/em\u003e\n\n\n**System information**\n- TensorFlow version: 1.0\n- Doc Link:\n\naccording to this issue #258 using following code to create a high dim tensor\n\u003e Yes, you need to convert your float array to a [`NdArray`](https://github.com/tensorflow/java/blob/r0.3/ndarray/src/main/java/org/tensorflow/ndarray/NdArray.java) using the [`StdArrays`](https://github.com/tensorflow/java/blob/r0.3/ndarray/src/main/java/org/tensorflow/ndarray/StdArrays.java) utilities, before initializing a tensor with it, i.e. \n\u003e \n\u003e ```\n\u003e \n\u003e TFloat32 t = TFloat32.tensorOf(StdArrays.ndCopyOf(floatImage));\n\u003e \n\u003e ``` \n\n _Originally posted by @karllessard in [#258](https://github.com/tensorflow/java/issues/258#issuecomment-809792979)_\n\nin `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\u003cT\u003e type, Shape shape, long size)` method and using `RawTenor` to allocate another memory area.\n\nis this two allocation necessary, and why we need this two allocation?\nor do we have any more optimized api to create a tensor with less memory allocation?\n\n@Craigacp \n\n\n**Describe the documentation issue**\n\n**We welcome contributions by users. Will you be able to update submit a PR (use the [doc style guide](https://www.tensorflow.org/community/documentation)) to fix the doc Issue?**\n","author":{"url":"https://github.com/wisper-shadow","@type":"Person","name":"wisper-shadow"},"datePublished":"2025-09-30T08:14:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/620/java/issues/620"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:436284af-c0bd-396b-e057-4d4bc4b01f46 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCDA:B32AB:2E07A77:3DD850D:69708219 |
| html-safe-nonce | 3cdb50440058a8ecaa64245a6b590ea479130bef78beecc913a14cf60e9aff21 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0RBOkIzMkFCOjJFMDdBNzc6M0REODUwRDo2OTcwODIxOSIsInZpc2l0b3JfaWQiOiI3MzA3ODM2Mjk5ODUyOTM5ODAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b60ff9404a6e385d78644ea5eac797e656f600628baefd9c799d9128bd15ee94 |
| hovercard-subject-tag | issue:3468110088 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/tensorflow/java/620/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30f19b8c8e9e04e877a9fdb9d9e4fb6390b4cf3780b5243c74761c1043577488/tensorflow/java/issues/620 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30f19b8c8e9e04e877a9fdb9d9e4fb6390b4cf3780b5243c74761c1043577488/tensorflow/java/issues/620 |
| og:image:alt | 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_t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wisper-shadow |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/tensorflow/java git https://github.com/tensorflow/java.git |
| octolytics-dimension-user_id | 15658638 |
| octolytics-dimension-user_login | tensorflow |
| octolytics-dimension-repository_id | 207384523 |
| octolytics-dimension-repository_nwo | tensorflow/java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 207384523 |
| octolytics-dimension-repository_network_root_nwo | tensorflow/java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width