Example #1
0
 def transpose(self, out=None):
     """
     Return a transposed view of the data.  Alias of .T property
     """
     if out:
         return OpTreeNode.build("assign", out, self.T)
     return self.T
Example #2
0
    def _assign(self, value):
        """
        Assign an input value to the CPU tensor. The NervanaCPU does clipping
        for int and uint types, when overflow happens

        Arguments:
            value (GPUTennsor, OpTreNode, numeric): the value to be assigned.

        """
        if isinstance(value, (CPUTensor, OpTreeNode)):
            OpTreeNode.build("assign", self, value)
        elif isinstance(value, (int, float, np.ndarray)):
            self.set(value)
        else:
            raise TypeError("Invalid type for assignment: %s" % type(value))

        return self