Skip to content

Commit

Permalink
implement Variable.xp
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaehashi committed Mar 19, 2018
1 parent e788405 commit ba6c412
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions chainer/variable.py
Expand Up @@ -487,6 +487,16 @@ def __repr__(self):
def __str__(self):
return variable_str(self)

@property
def xp(self):
"""Array module for this variable.
Depending on which of CPU/GPU this variable is on, this property
returns :mod:`numpy` or :mod:`cupy`.
"""
return cuda.get_array_module(self)

@property
def name(self):
return self._node.name
Expand Down

0 comments on commit ba6c412

Please sign in to comment.