| 52 | } |
| 53 | |
| 54 | Status GenerateCode(const GenerationContext& ctx, |
| 55 | GeneratedCode* generated_code) const final { |
| 56 | if (!IsSupported(ctx)) { |
| 57 | return InvalidArgumentError( |
| 58 | "This case is not supported by apply mask operation"); |
| 59 | } |
| 60 | const auto inputs = ctx.graph->FindInputs(ctx.node->id); |
| 61 | const auto& shape0 = inputs[0]->tensor.shape; |
| 62 | const auto& shape1 = inputs[1]->tensor.shape; |
| 63 | |
| 64 | std::string source = "value_0 = $input_data_0[gid.x, gid.y, gid.z]$ * "; |
| 65 | if (shape1.c == 1) { |
| 66 | // [H, W, C] x [H, W, 0][0] |
| 67 | absl::StrAppend(&source, "$input_data_1[gid.x, gid.y, 0]$.x;"); |
| 68 | } else if (shape0.h == shape1.h && shape0.w == shape1.w) { |
| 69 | // [H, W, C] x [H, W, C] |
| 70 | absl::StrAppend(&source, "$input_data_1[gid.x, gid.y, gid.z]$;"); |
| 71 | } else { |
| 72 | // [H, W, C] x [0, 0, C] |
| 73 | absl::StrAppend(&source, "$input_data_1[0, 0, gid.z]$;"); |
| 74 | } |
| 75 | |
| 76 | *generated_code = { |
| 77 | /*parameters=*/{}, |
| 78 | /*objects=*/{}, |
| 79 | /*shared_variables=*/{}, |
| 80 | /*workload=*/uint3(), |
| 81 | /*workgroup=*/uint3(), |
| 82 | /*source_code=*/std::move(source), |
| 83 | /*input=*/IOStructure::ONLY_DEFINITIONS, |
| 84 | /*output=*/IOStructure::AUTO, |
| 85 | }; |
| 86 | return OkStatus(); |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | class MultiplyScalar : public NodeShader { |
nothing calls this directly
no test coverage detected