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

Add Tanh, Range and Pow OpCodeGenerators and fix assert when dir exists #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alealv
Copy link

@alealv alealv commented Jul 21, 2021

No description provided.

@Z223I
Copy link

Z223I commented Jul 31, 2021

@alealv Here is the assert fix:
Change /home/username/venvonnx/lib/python3.8/site-packages/onnx_pytorch/code_gen.py
You already have a soln. For others out there...
def gen(onnx_model,
output_dir,
overwrite=False,
tensor_inplace=False,
simplify_names=False,
continue_on_error=False):
kwargs = {
"output_dir": output_dir,
"simplify_names": simplify_names,
"tensor_inplace": tensor_inplace,
"continue_on_error": continue_on_error,
}
if type(onnx_model) == onnx.ModelProto:
kwargs["onnx_model"] = onnx_model
else:

        if os.path.exists(output_dir):
            pathExists = True
            print(f"{output_dir} exists.")
        else:
            pathExists = False
            print(f"{output_dir} does not exists.")
        print(f"overwrite: {overwrite}")

        assert os.path.exists(
            onnx_model), f"ONNX model {onnx_model} does not exist."
        assert os.path.isfile(onnx_model), f"{onnx_model} is not a file."

        if pathExists and overwrite != True:
            print(f"{output_dir} exists and overwrite is not True.")

        if os.path.exists(output_dir):
            assert overwrite, f"{output_dir} exists and overwrite is not True."

        assert os.path.isdir(output_dir), f"{output_dir} is not directory."
        kwargs["onnx_model"] = onnx.load(onnx_model)
    if overwrite:
        shutil.rmtree(output_dir, ignore_errors=True)
        os.makedirs(output_dir)
    ModelCodeGenerator(**kwargs).run()

@fumihwh
Copy link
Owner

fumihwh commented Aug 16, 2021

@alealv Thanks for contribution.
Maybe conflict with earlier PR, just wait to merge.

@fumihwh fumihwh mentioned this pull request Aug 16, 2021
@alealv
Copy link
Author

alealv commented Aug 26, 2021

Sorry for the late reply. I didn't get your answer, what do you want me to change?

I just rebase to master.

@fumihwh
Copy link
Owner

fumihwh commented Aug 28, 2021

@alealv Could you add test cases for pow and range op?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants