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: github.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:d00dc3b0-8236-59c1-d375-2ddf8d0dfd30 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCFC:2943C4:C7BE76:1192A15:696A6414 |
| html-safe-nonce | d4c813d406da61f835065e789578de058a938091c3cd54a1bf50a33d99b811d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0ZDOjI5NDNDNDpDN0JFNzY6MTE5MkExNTo2OTZBNjQxNCIsInZpc2l0b3JfaWQiOiI2NzM2ODAzMzcyNTk4OTc3NTU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 200f3c26faa832e63f006dd7e67ef32e20f27d25d4fb93d17996e8f0d7624876 |
| 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 | 9b7735a184970dd9333b2cbe036c8f3c0a9108c64aaa93827c5a64fc70993392 |
| 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 | 87cbd411c2982752221b5751d583a515b23bf5fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width