Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 7623f0b

Browse files
author
Nicolas Vasilache
committed
Fix multiple definitions
This commit fixes multiple definitions issues in the caffe2 test harness. This was caught internally when building on FB Infra.
1 parent 020faf0 commit 7623f0b

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

test/caffe2/test_harness-inl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ namespace caffe2 {
1919

2020
namespace detail {
2121

22-
std::mutex& RNGMutex() {
23-
static std::mutex rng_mutex;
24-
return rng_mutex;
25-
}
22+
std::mutex& RNGMutex();
2623

2724
template <typename T>
2825
T* NewTensor(

test/caffe2/test_harness.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
#include "test_harness.h"
1717

1818
namespace caffe2 {
19+
namespace detail {
20+
21+
std::mutex& RNGMutex() {
22+
static std::mutex rng_mutex;
23+
return rng_mutex;
24+
}
25+
26+
} // namespace detail
27+
28+
ReferenceImplementationBuilder MakeDefaultReferenceImplementationBuilder() {
29+
return [](const OperatorDef& op_def, NetDef* net_def) {
30+
caffe2::ReferenceImplementationRegistry::Append(net_def, op_def);
31+
};
32+
}
1933

2034
void CheckEqual(
2135
const caffe2::Tensor<caffe2::CPUContext>& Texpected,

test/caffe2/test_harness.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ at::Tensor MakeAtenTensor(
8787
using ReferenceImplementationBuilder =
8888
std::function<void(const OperatorDef& op_def, NetDef* net_def)>;
8989

90-
ReferenceImplementationBuilder MakeDefaultReferenceImplementationBuilder() {
91-
return [](const OperatorDef& op_def, NetDef* net_def) {
92-
caffe2::ReferenceImplementationRegistry::Append(net_def, op_def);
93-
};
94-
}
90+
ReferenceImplementationBuilder MakeDefaultReferenceImplementationBuilder();
9591

9692
/// Creates an OperatorDef for a particular Backend
9793
/// op_name is the name of the operator (e.g. TcOp)

0 commit comments

Comments
 (0)