Skip to content

Commit 7973d10

Browse files
Johannes Ball?copybara-github
authored andcommitted
Removes ArrayFingerprint op.
PiperOrigin-RevId: 258815969 Change-Id: Ibfaec0be0bbf92dce7a1e0e0c2b92f70813b549f
1 parent ab714b9 commit 7973d10

File tree

3 files changed

+0
-93
lines changed

3 files changed

+0
-93
lines changed

tensorflow_compression/cc/kernels/range_coding_helper_kernels.cc

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ limitations under the License.
3131
#include "tensorflow/core/platform/logging.h"
3232
#include "tensorflow/core/platform/macros.h"
3333
#include "tensorflow/core/platform/types.h"
34-
#include "external/farmhash_archive/src/farmhash.h"
3534

3635
namespace tensorflow_compression {
3736
namespace {
@@ -207,30 +206,5 @@ class PmfToCdfOp : public OpKernel {
207206
REGISTER_KERNEL_BUILDER(Name("PmfToQuantizedCdf").Device(DEVICE_CPU),
208207
PmfToCdfOp);
209208

210-
class ArrayFingerprintOp : public tensorflow::OpKernel {
211-
public:
212-
using OpKernel::OpKernel;
213-
214-
void Compute(tensorflow::OpKernelContext* context) override {
215-
const Tensor& input = context->input(0);
216-
OP_REQUIRES(context, tensorflow::DataTypeCanUseMemcpy(input.dtype()),
217-
InvalidArgument("Data type not supported: ",
218-
tensorflow::DataTypeString(input.dtype())));
219-
220-
const int64 size =
221-
input.shape().num_elements() * tensorflow::DataTypeSize(input.dtype());
222-
auto data = input.bit_casted_shaped<char, 1>({size});
223-
224-
Tensor* output;
225-
OP_REQUIRES_OK(context,
226-
context->allocate_output(0, TensorShape{}, &output));
227-
228-
output->scalar<int64>()() =
229-
::util::Fingerprint64(data.data(), static_cast<size_t>(data.size()));
230-
}
231-
};
232-
233-
REGISTER_KERNEL_BUILDER(Name("ArrayFingerprint").Device(tensorflow::DEVICE_CPU),
234-
ArrayFingerprintOp);
235209
} // namespace
236210
} // namespace tensorflow_compression

tensorflow_compression/cc/kernels/range_coding_helper_kernels_test.cc

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -150,62 +150,6 @@ TEST_F(PmfToQuantizedCdfOpTest, ShapeFn) {
150150
INFER_OK(op, "[3,4,5]", "[d0_0,d0_1,6]");
151151
}
152152

153-
class FingerprintOpTest : public tensorflow::OpsTestBase {
154-
protected:
155-
void MakeFingerprintOp(Tensor* tensor) {
156-
TF_ASSERT_OK(tensorflow::NodeDefBuilder("fingerprint", "ArrayFingerprint")
157-
.Input(tensorflow::FakeInput(tensor->dtype()))
158-
.Finalize(node_def()));
159-
TF_ASSERT_OK(InitOp());
160-
161-
inputs_.clear();
162-
inputs_.emplace_back(tensor);
163-
}
164-
};
165-
166-
TEST_F(FingerprintOpTest, Verify) {
167-
std::random_device rd;
168-
random::PhiloxRandom gen(rd(), rd());
169-
random::SimplePhilox rand(&gen);
170-
for (tensorflow::DataType dtype : tensorflow::kRealNumberTypes) {
171-
const int rank = rand.Uniform(4);
172-
173-
TensorShape shape;
174-
for (int i = 0; i < rank; ++i) {
175-
shape.AddDim(rand.Uniform(9) + 1);
176-
}
177-
178-
Tensor tensor(dtype, shape);
179-
180-
const int64 length = shape.num_elements() * tensorflow::DataTypeSize(dtype);
181-
auto buffer = tensor.bit_casted_shaped<char, 1>({length});
182-
buffer.setRandom();
183-
184-
MakeFingerprintOp(&tensor);
185-
TF_ASSERT_OK(RunOpKernel());
186-
Tensor fingerprint0 = *GetOutput(0);
187-
188-
// Change one byte in the buffer.
189-
const int64 pos = rand.Uniform(length);
190-
buffer(pos) = ~buffer(pos);
191-
192-
MakeFingerprintOp(&tensor);
193-
TF_ASSERT_OK(RunOpKernel());
194-
Tensor fingerprint1 = *GetOutput(0);
195-
196-
EXPECT_NE(fingerprint0.tensor_data(), fingerprint1.tensor_data());
197-
}
198-
}
199-
200-
TEST_F(FingerprintOpTest, FingerprintShapeFn) {
201-
tensorflow::ShapeInferenceTestOp op("ArrayFingerprint");
202-
203-
INFER_OK(op, "?", "[]");
204-
INFER_OK(op, "[]", "[]");
205-
INFER_OK(op, "[1]", "[]");
206-
INFER_OK(op, "[1,2]", "[]");
207-
INFER_OK(op, "[1,2,3]", "[]");
208-
}
209153
} // namespace
210154
} // namespace tensorflow_compression
211155

tensorflow_compression/cc/ops/range_coding_ops.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,5 @@ by this op prior to quantization. Therefore the user is responsible for
270270
normalizing PMF if necessary.
271271
)doc");
272272

273-
REGISTER_OP("ArrayFingerprint")
274-
.Input("input: T")
275-
.Output("fingerprint: int64")
276-
.Attr("T: realnumbertype")
277-
.SetShapeFn(shape_inference::ScalarShape)
278-
.Doc(R"doc(
279-
Produces fingerprint of the input data.
280-
281-
input: Tensor to be fingerprinted.
282-
fingerprint: Fingerprint value of input.
283-
)doc");
284273
} // namespace
285274
} // namespace tensorflow_compression

0 commit comments

Comments
 (0)