MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Compile

Method Compile

tensorflow/compiler/tf2xla/kernels/image_ops.cc:138–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 explicit HSVToRGBOp(OpKernelConstruction* context) : XlaOpKernel(context) {}
137
138 void Compile(XlaOpKernelContext* context) override {
139 const TensorShape input_shape = context->InputShape(0);
140 OP_REQUIRES(context, input_shape.dims() >= 1,
141 errors::InvalidArgument("input must be at least 1D",
142 input_shape.DebugString()));
143 int channel_dim = input_shape.dims() - 1;
144 int64 channels = input_shape.dim_size(channel_dim);
145 OP_REQUIRES(
146 context, channels == 3,
147 errors::FailedPrecondition("input must have 3 channels but input has ",
148 channels, " channels."));
149
150 xla::XlaBuilder* b = context->builder();
151 xla::XlaOp input = context->Input(0);
152 xla::XlaOp hue = xla::SliceInDim(input, /*start_index=*/0,
153 /*limit_index=*/1, /*stride=*/1,
154 /*dimno=*/channel_dim);
155 xla::XlaOp saturation = xla::SliceInDim(input, /*start_index=*/1,
156 /*limit_index=*/2, /*stride=*/1,
157 /*dimno=*/channel_dim);
158 xla::XlaOp value = xla::SliceInDim(input, /*start_index=*/2,
159 /*limit_index=*/3, /*stride=*/1,
160 /*dimno=*/channel_dim);
161
162 auto rgb = HSVToRGB(context->builder(), {hue, saturation, value},
163 context->input_type(0));
164
165 context->SetOutput(0, xla::ConcatInDim(b, rgb, channel_dim));
166 }
167};
168REGISTER_XLA_OP(Name("HSVToRGB"), HSVToRGBOp);
169

Callers

nothing calls this directly

Calls 13

InvalidArgumentFunction · 0.85
FailedPreconditionFunction · 0.85
SliceInDimFunction · 0.85
ConcatInDimFunction · 0.85
InputShapeMethod · 0.80
HSVToRGBFunction · 0.70
dimsMethod · 0.45
DebugStringMethod · 0.45
dim_sizeMethod · 0.45
builderMethod · 0.45
InputMethod · 0.45
input_typeMethod · 0.45

Tested by

no test coverage detected