move matrix formation for dot products to precompute/request-only (#10531)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10531
fixed a naming issue in pairwise_similarity
Reviewed By: huayuli00
Differential Revision: D9331716
fbshipit-source-id: d7de36f20504c08b1c7871ccdffa343221a3da0c
diff --git a/caffe2/python/layers/pairwise_similarity.py b/caffe2/python/layers/pairwise_similarity.py
index 300c2f3..76f63a0 100644
--- a/caffe2/python/layers/pairwise_similarity.py
+++ b/caffe2/python/layers/pairwise_similarity.py
@@ -68,13 +68,13 @@
y_embeddings_norm = net.Normalize(self.y_embeddings(), axis=1)
Y = net.BatchMatMul(
[x_embeddings_norm, y_embeddings_norm],
- [x_embeddings_norm + '_matmul'],
+ [self.get_next_blob_reference(x_embeddings_norm + '_matmul')],
trans_b=1,
)
elif self.pairwise_similarity_func == "dot":
Y = net.BatchMatMul(
[self.x_embeddings(), self.y_embeddings()],
- [self.x_embeddings() + '_matmul'],
+ [self.get_next_blob_reference(self.x_embeddings() + '_matmul')],
trans_b=1,
)
else: