Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NewIR]Remove compatible logic of ProgramTranslator #55453

Merged
merged 18 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions paddle/fluid/ir_adaptor/translator/op_compat_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
undefined=StrictUndefined,
extensions=['jinja2.ext.do'],
)
grad_suffix = '_grad'


def OpNameNormalizerInitialization(
Expand Down Expand Up @@ -86,7 +87,7 @@ def insert_new_mutable_attributes(
attribute_name
].append(v)

_, legacy_name = insert_new_mappings(op_compat_item["op"])
phi_name, legacy_name = insert_new_mappings(op_compat_item["op"])
legacy_backward_op_names = []
if "backward" in op_compat_item:
backward_op_name_mapping_paris = op_compat_item["backward"].split(
Expand All @@ -95,6 +96,10 @@ def insert_new_mutable_attributes(
for pair in backward_op_name_mapping_paris:
_, legacy_backward_op_name = insert_new_mappings(pair)
legacy_backward_op_names.append(legacy_backward_op_name)
elif phi_name != legacy_name:
legacy_backward_op_name = legacy_name + grad_suffix
legacy_backward_op_names.append(legacy_backward_op_name)
op_name_mappings[legacy_backward_op_name] = phi_name + grad_suffix
kangguangli marked this conversation as resolved.
Show resolved Hide resolved
kangguangli marked this conversation as resolved.
Show resolved Hide resolved

if "inputs" in op_compat_item:
insert_new_arg_mappings(legacy_name, op_compat_item["inputs"])
Expand Down Expand Up @@ -126,9 +131,6 @@ def insert_new_mutable_attributes(
backward_op, op_compat_item["scalar"]
)

# special op mappings
op_name_mappings["fetch_v2"] = "fetch"

op_name_normailzer_template = env.get_template("op_compat_info.cc.j2")
with open(output_source_file, 'wt') as f:
op_compat_definition = op_name_normailzer_template.render(
Expand Down
6 changes: 2 additions & 4 deletions paddle/fluid/ir_adaptor/translator/op_compat_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include "glog/logging.h"

#include "paddle/fluid/ir_adaptor/translator/utils.h"

#pragma once

namespace paddle {
Expand Down Expand Up @@ -106,11 +104,11 @@ class OpNameNormalizer {
return legacy_name;
}
if (op_arg_name_mappings.find(op_type) == op_arg_name_mappings.end()) {
return UnderscoreToCamelCase(arg_name);
return arg_name;
Asthestarsfalll marked this conversation as resolved.
Show resolved Hide resolved
}
auto& arg_mappings = op_arg_name_mappings[op_type];
if (arg_mappings.find(arg_name) == arg_mappings.end()) {
return UnderscoreToCamelCase(arg_name);
return arg_name;
}
return arg_mappings.at(arg_name);
}
Expand Down
42 changes: 0 additions & 42 deletions paddle/fluid/ir_adaptor/translator/utils.h

This file was deleted.

24 changes: 23 additions & 1 deletion paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3027,11 +3027,27 @@
yolo_loss : GetYoloLossExpectedKernelType
yolo_loss_grad : GetYoloLossExpectedKernelType

- op: fetch
- op: channel_shuffle
inputs:
{x: X}
outputs:
{out: Out}

- op: fetch (fetch_v2)
inputs: {x: X}
outputs: {out: Out}

- op: full_batch_size_like (fill_constant_batch_size_like)
inputs:
{input: Input}
outputs:
{out: Out}

- op: logspace
inputs:
{start: Start, stop: Stop, num: Num, base: Base}
outputs:
{out: Out}

- op: lu
backward: lu_grad
Expand All @@ -3048,6 +3064,12 @@
outputs :
{reindex_src : Reindex_Src, reindex_dst : Reindex_Dst, out_nodes : Out_Nodes}

- op: rrelu
inputs:
{x: X}
outputs:
{out: Out, Noise: noise}

- op: sigmoid_cross_entropy_with_logits
backward: sigmoid_cross_entropy_with_logits_grad
inputs :
Expand Down