def _create_var(name, value): dtype = plaidml.DType.from_numpy(value.dtype) shape = edsl.LogicalShape(dtype, value.shape) tensor_shape = plaidml.TensorShape(dtype, value.shape) buffer = plaidml.Buffer(_device, tensor_shape) buffer.copy_from_ndarray(value) return edsl.Tensor(shape=shape, name=name, buffer=buffer)
def make_buffer(tensor): # convert LogicalShape into TensorShape shape = plaidml.TensorShape(tensor.shape.dtype, tensor.shape.int_dims) return plaidml.Buffer(_device, shape)
def set_value(x, value): dtype = plaidml.DType.from_numpy(value.dtype) tensor_shape = plaidml.TensorShape(dtype, value.shape) buffer = plaidml.Buffer(_device, tensor_shape) buffer.copy_from_ndarray(value) x.tensor.set_param_value(buffer)