Skip to content

Commit 956a25d

Browse files
Mike Ruberryfacebook-github-bot
Mike Ruberry
authored andcommittedSep 24, 2020
Revert D23858329: [PT Model Split] Support 2 operators in PT by C2 conversion
Test Plan: revert-hammer Differential Revision: D23858329 (pytorch@721cfbf) Original commit changeset: ed37118ca7f0 fbshipit-source-id: 30c700f80665be11afc608b00a77766064e60b35
1 parent 2d00ebd commit 956a25d

File tree

3 files changed

+1
-79
lines changed

3 files changed

+1
-79
lines changed
 

‎caffe2/operators/gather_ranges_to_dense_op.cc

-8
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,3 @@ NO_GRADIENT(GatherRangesToDense);
104104

105105
} // namespace
106106
} // namespace caffe2
107-
108-
using GatherRangesToDenseCPUOp =
109-
caffe2::GatherRangesToDenseOp<caffe2::CPUContext>;
110-
111-
C10_EXPORT_CAFFE2_OP_TO_C10_CPU(
112-
GatherRangesToDense,
113-
"_caffe2::GatherRangesToDense(Tensor data, Tensor ranges, Tensor? key, int[] lengths, int min_observation, float max_mismatched_ratio, float max_empty_ratio) -> Tensor[] outputs",
114-
GatherRangesToDenseCPUOp);

‎caffe2/operators/gather_ranges_to_dense_op.h

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "caffe2/core/common_omp.h"
77
#include "caffe2/core/context.h"
8-
#include "caffe2/core/export_caffe2_op_to_c10.h"
98
#include "caffe2/core/logging.h"
109
#include "caffe2/core/operator.h"
1110
#include "caffe2/core/types.h"
@@ -16,8 +15,6 @@
1615
#include <map>
1716
#include <utility>
1817

19-
C10_DECLARE_EXPORT_CAFFE2_OP_TO_C10(GatherRangesToDense);
20-
2118
namespace caffe2 {
2219
template <class Context>
2320
class GatherRangesToDenseOp final : public Operator<Context> {

‎caffe2/python/operator_test/torch_integration_test.py

+1-68
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
import torch
88
import unittest
99

10-
from caffe2.python import core, dyndep, workspace
10+
from caffe2.python import core, workspace
1111
from hypothesis import given, settings
1212
from scipy.stats import norm
1313

14-
dyndep.InitOpsLibrary('@/caffe2/caffe2/fb/operators:calibration_op')
15-
1614

1715
def generate_rois(roi_counts, im_dims):
1816
assert len(roi_counts) == len(im_dims)
@@ -877,71 +875,6 @@ def _batch_bucket_one_hot_ref(data, lengths, boundaries):
877875
)
878876
torch.testing.assert_allclose(expected_output, actual_output.cpu())
879877

880-
def test_gather_ranges_to_dense_op(self):
881-
data = np.array([1, 2, 3, 4, 5, 6, 7, 8])
882-
ranges = np.array([[[2, 4]], [[0, 0]]])
883-
key = np.array([0, 1, 3, 2, 1, 0, 1, 0])
884-
lengths = np.array([4])
885-
min_observation = 2
886-
max_mismatched_ratio = 0.5
887-
max_empty_ratio = 1.0
888-
889-
outputs_name = ["X_{}".format(i) for i in range(len(lengths))]
890-
ref_op = core.CreateOperator(
891-
"GatherRangesToDense",
892-
["data", "ranges", "key"],
893-
outputs_name,
894-
lengths=lengths,
895-
min_observation=min_observation,
896-
max_mismatched_ratio=max_mismatched_ratio,
897-
max_empty_ratio=max_empty_ratio,
898-
)
899-
workspace.FeedBlob("data", data)
900-
workspace.FeedBlob("ranges", ranges)
901-
workspace.FeedBlob("key", key)
902-
workspace.RunOperatorOnce(ref_op)
903-
ref_outputs = []
904-
for output_name in outputs_name:
905-
ref_outputs.append(workspace.FetchBlob(output_name))
906-
907-
outputs = torch.ops._caffe2.GatherRangesToDense(
908-
torch.from_numpy(data),
909-
torch.from_numpy(ranges),
910-
torch.from_numpy(key),
911-
lengths=lengths,
912-
min_observation=min_observation,
913-
max_mismatched_ratio=max_mismatched_ratio,
914-
max_empty_ratio=max_empty_ratio,
915-
)
916-
917-
self.assertEqual(len(ref_outputs), len(outputs))
918-
for i in range(0, len(ref_outputs)):
919-
np.testing.assert_array_almost_equal(ref_outputs[i], outputs[i].numpy())
920-
921-
def test_prior_correct_calibration_prediction_op(self):
922-
beta = np.array([1.0, 2.0], dtype=np.float32)
923-
gamma = np.array([3.0, 4.0], dtype=np.float32)
924-
pred = np.array([0.1, 0.2, 0.3, 0.4], dtype=np.float32)
925-
926-
ref_op = core.CreateOperator(
927-
"PriorCorrectionCalibrationPrediction",
928-
["beta", "gamma", "pred"],
929-
["new_pred"],
930-
)
931-
workspace.FeedBlob("beta", beta)
932-
workspace.FeedBlob("gamma", gamma)
933-
workspace.FeedBlob("pred", pred)
934-
workspace.RunOperatorOnce(ref_op)
935-
ref_output = workspace.FetchBlob("new_pred")
936-
937-
output = torch.ops._caffe2.PriorCorrectionCalibrationPrediction(
938-
torch.from_numpy(beta),
939-
torch.from_numpy(gamma),
940-
torch.from_numpy(pred),
941-
)
942-
torch.testing.assert_allclose(ref_output, output)
943-
944-
945878
@given(lengths_0=st.integers(1, 10), lengths_1=st.integers(1, 10))
946879
@settings(deadline=1000)
947880
def test_merge_id_lists(self, lengths_0, lengths_1):

0 commit comments

Comments
 (0)
Please sign in to comment.