提交 be928cf3 编写于 作者: S Siddharth Agrawal 提交者: Vijay Vasudevan

Enable GPU for L2Loss float64 (#2352)

* Enable GPU for L2Loss float64

* Enable GPU for L2Loss float64
上级 4c789e39
......@@ -68,6 +68,7 @@ namespace functor {
extern template struct L2Loss<GPUDevice, T>;
DECLARE_GPU_SPEC(float);
DECLARE_GPU_SPEC(double);
DECLARE_GPU_SPEC(Eigen::half);
#undef DECLARE_GPU_SPEC
} // namespace functor
......@@ -79,6 +80,7 @@ DECLARE_GPU_SPEC(Eigen::half);
L2LossOp<GPUDevice, T>);
REGISTER_GPU_KERNEL(float);
REGISTER_GPU_KERNEL(double);
REGISTER_GPU_KERNEL(Eigen::half);
#undef REGISTER_GPU_KERNEL
......
......@@ -25,6 +25,7 @@ namespace tensorflow {
typedef Eigen::GpuDevice GPUDevice;
template struct functor::L2Loss<GPUDevice, float>;
template struct functor::L2Loss<GPUDevice, double>;
template struct functor::L2Loss<GPUDevice, Eigen::half>;
} // namespace tensorflow
......
......@@ -116,11 +116,13 @@ class LogSoftmaxTest(tf.test.TestCase):
class L2LossTest(tf.test.TestCase):
def testL2Loss(self):
with self.test_session():
x = tf.constant([1.0, 0.0, 3.0, 2.0], shape=[2, 2], name="x")
l2loss = tf.nn.l2_loss(x)
value = l2loss.eval()
self.assertAllClose(7.0, value)
for dtype in [tf.float32, tf.float64]:
with self.test_session():
x = tf.constant([1.0, 0.0, 3.0, 2.0], shape=[2, 2], name="x",
dtype=dtype)
l2loss = tf.nn.l2_loss(x)
value = l2loss.eval()
self.assertAllClose(7.0, value)
def testGradient(self):
x_shape = [20, 7, 3]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册