{
"id": "fn-gpu-to_tensor",
"dataComponent": "gpu",
"heading": {
"title": "to_tensor",
"badges": ["GPU"]
},
"synopsis": "Converts an int2D_array or float2D_array into a GPU-ready float32 tensor (rank=2). Logs an error if shape is inconsistent or data is empty.",
"codeBlocks": [
"extend(\"gpu\")\\n\\n# 1) Convert 2D int array => rank=2 float32 tensor\\narrI = [[1,2],[3,4],[5,6]]\\nT = gpu:to_tensor(arrI)\\nslog(T)\\n# => TensorValue(...) with shape=[3,2], elem_type=Float32\\n\\n# 2) Convert 2D float array => same concept\\narrF = [[1.1,2.2],[3.3,4.4]]\\nTF = gpu:to_tensor(arrF)\\nslog(TF)\\n# => shape=[2,2], data as float32\\n\\n# If bridging sees an empty array or ragged rows, it raises an error.\\n"
],
"notes": [
"gpu:to_tensor => exactly 1 argument: a 2D array (either int2D_array or float2D_array). The resulting shape is [rows, cols].",
"All values become float32. If rows differ in length, bridging fails with an 'inconsistent row lengths' error.",
"Used as the first step for GPU ops like multiply, add, etc."
]
}