1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5 http://www.apache.org/licenses/LICENSE-2.0
6 Unless required by applicable law or agreed to in writing, software
7 distributed under the License is distributed on an "AS IS" BASIS,
8 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 See the License for the specific language governing permissions and
10 limitations under the License.
11 ==============================================================================*/
12
13 #include "tensorflow/c/ops.h"
14 #include "tensorflow/c/tf_status.h"
15 #include "tensorflow/core/framework/registration/registration.h"
16 #include "tensorflow/core/platform/logging.h"
17 #include "tensorflow/core/platform/macros.h"
18
histogram_summary_shape_inference_fn(TF_ShapeInferenceContext * ctx,TF_Status * status)19 static void histogram_summary_shape_inference_fn(TF_ShapeInferenceContext* ctx,
20 TF_Status* status) {
21 TF_SetStatus(status, TF_OK, "");
22 TF_ShapeHandle* result = TF_ShapeInferenceContextScalar(ctx);
23 TF_ShapeInferenceContextSetOutput(ctx, 0, result, status);
24 TF_DeleteShapeHandle(result);
25 }
26
Register_HistogramSummaryOp()27 void Register_HistogramSummaryOp() {
28 TF_Status* status = TF_NewStatus();
29
30 TF_OpDefinitionBuilder* op_builder =
31 TF_NewOpDefinitionBuilder("HistogramSummary");
32 TF_OpDefinitionBuilderAddInput(op_builder, "tag: string");
33 TF_OpDefinitionBuilderAddInput(op_builder, "values: T");
34 TF_OpDefinitionBuilderAddOutput(op_builder, "summary: string");
35 TF_OpDefinitionBuilderAddAttr(op_builder, "T: realnumbertype = DT_FLOAT");
36 TF_OpDefinitionBuilderSetShapeInferenceFunction(
37 op_builder, &histogram_summary_shape_inference_fn);
38
39 TF_RegisterOpDefinition(op_builder, status);
40 CHECK_EQ(TF_GetCode(status), TF_OK)
41 << "HistogramSummary op registration failed: " << TF_Message(status);
42 TF_DeleteStatus(status);
43 }
44
__anon65278eb00102() 45 TF_ATTRIBUTE_UNUSED static bool HistogramSummaryOpRegistered = []() {
46 if (SHOULD_REGISTER_OP("HistogramSummary")) {
47 Register_HistogramSummaryOp();
48 }
49 return true;
50 }();
51