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 _get_buffer(self, map, arg): buffer = map.get(arg.ref) if buffer: return buffer buffer = plaidml.Buffer(arg.shape.into_TensorShape(), device=self.device) map[arg.ref] = buffer return 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 make_buffer(tensor): # convert LogicalShape into TensorShape return plaidml.Buffer(device, tensor.shape.into_TensorShape())
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)