liuliu/s4nnc

How to copy data to a variable from a tensor?

Closed this issue · 1 comments

i tried

graph!.variable(Tensor<Float16>(ten))[0..<320, 0..<320, 0..<3, 0..<3] =  graph!.variable(Tensor<Float16>(cached_weights[name]))[0..<320, 0..<320, 0..<3, 0..<3] 

both ten and cached_weights[name] are any tensors.

I get this error:
examples/dylib_interface.swift:114:56: error: cannot assign through subscript: function call returns immutable value

liuliu commented
variable[0..<320, 0..<320, 0..<3, 0..<3] = graph.variable(tensor[0..<320, 0..<320, 0..<3, 0..<3])

You cannot create a variable inplace and assign values.