提交 aaf09989 authored 作者: James Bergstra's avatar James Bergstra

added some code comments regarding elemwise

上级 ace63e7a
...@@ -68,6 +68,15 @@ class GpuElemwise(Op): ...@@ -68,6 +68,15 @@ class GpuElemwise(Op):
nout = property(lambda self: self.scalar_op.nout) nout = property(lambda self: self.scalar_op.nout)
def __init__(self, scalar_op, inplace_pattern): def __init__(self, scalar_op, inplace_pattern):
##
# TODO: implement inplace operations.
# It's ok that we set the DestroyMap to something but then don't actually destroy
# anything. It's just a bit of a waste of memory.
#
# As current GPUs don't have cache, this probably doesn't make any difference to
# the amount of loading and storing to global memory that we would have to do.
# That's why it isn't implemented yet.
#
self.scalar_op = scalar_op self.scalar_op = scalar_op
self.inplace_pattern = inplace_pattern self.inplace_pattern = inplace_pattern
self.destroy_map = dict((o, [i]) for o, i in inplace_pattern.items()) self.destroy_map = dict((o, [i]) for o, i in inplace_pattern.items())
......
...@@ -626,6 +626,19 @@ class NaiveAlgo(object): ...@@ -626,6 +626,19 @@ class NaiveAlgo(object):
return sio.getvalue() return sio.getvalue()
def c_src_callkernel(self, node, nodename): def c_src_callkernel(self, node, nodename):
#
# This function serves two main goals:
#
# The first is stride unpacking:
# it accepts input and output arguments as
# float * , int*
# pairs, and it constructs a kernel function call where inputs and arguments are named
# like
# float *, int, int, int ...
#
# The second is to recognize when trailing (right-most in numpy) dimensions can be collapsed as
# being contiguous... (confusing... read code)
#
nd = node.outputs[0].type.ndim nd = node.outputs[0].type.ndim
id_self = id(self) id_self = id(self)
d = dict() d = dict()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论