Exemple #1
0
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)
Exemple #2
0
 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
Exemple #3
0
 def make_buffer(tensor):
     # convert LogicalShape into TensorShape
     shape = plaidml.TensorShape(tensor.shape.dtype, tensor.shape.int_dims)
     return plaidml.Buffer(_device, shape)
Exemple #4
0
 def make_buffer(tensor):
     # convert LogicalShape into TensorShape
     return plaidml.Buffer(device, tensor.shape.into_TensorShape())
Exemple #5
0
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)