outFrom

infix fun Tensor.outFrom(jsVarName: String): Pipeline.JavaScriptIO

Define a relationship between a Tensor and a JS var in the JavaScript script to be executed by Pipeline.runJavaScript that: will write the content of the specified JS var to the tensor after the JavaScript's execution is done. The JS var will be initialized as an all-zero JS array of the corresponding datatype, with length = the total count of elements in the Tensor.

Return

A JavaScriptIO describing the relationship that the tensor's data will initialized the JavaScript var jsVarName and the former's value will be updated using the content copied out from the later.

Parameters

jsVarName

the name of the JS var in the JavaScript script to be executed by Pipeline.runJavaScript. The JS var jsVarName will be initialized as a JS Array of floats, of length equal to the total count of elements in this tensor, whose content will be initialized with the content of this tensor's content at run time. The initial value of the JS var jsVarName will be all zero.

Note the JS var must not be initialized in the script. The JS var will be initialized by the SpatialML based on the datatype and the total count of elements in this tensor at run time. For example, if you:

var tensor1 = newLocalTensor(MultiDimensionalInitInfo(DataType.FLOAT32, intArrayOf(2, 3)))
tensor1 into "my_js_var"

The JS var called my_js_var will be initialized as a JS Array of floats, of length 6, because the tensor1 is an FLOAT32 tensor of 2x3 = 6 elements in total. If the

The following JavaScript codes are wrong, because it initializes the JS var in the script, conflicting with the relationship defined above.

var my_js_var = [1.0, 2.0, 3.0];

Instead, your JavaScript codes should be:

var my_js_var;
my_js_var[0] = 2.0;
...

Because the my_js_var will be initialized with the tensor1 at runtime.