-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple source_to_source demo for nightly tests
- Loading branch information
1 parent
ea71fcd
commit 150f0fa
Showing
3 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install -q ivy kornia" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ivy\n", | ||
"import torch\n", | ||
"import tensorflow as tf\n", | ||
"import kornia\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Cache database created at /Users/samuelarmstrong/Documents/ivy/demos/examples_and_demos/.ivy/cache.sqlite.\n", | ||
"Graph cache table created.\n", | ||
"Autotune cache table created.\n" | ||
] | ||
}, | ||
{ | ||
"ename": "IvyException", | ||
"evalue": "Unable to find an api key in the IVY_KEY env var, or ivy-key.pem file.", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mIvyException\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m tf_rgb_to_grayscale \u001b[38;5;241m=\u001b[39m \u001b[43mivy\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msource_to_source\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkornia\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrgb_to_grayscale\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msource\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtorch\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtensorflow\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/ivy/compiler/compiler.py:44\u001b[0m, in \u001b[0;36msource_to_source\u001b[0;34m(object, source, target, profiling)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Converts a given object (class/function) from one framework to another.\u001b[39;00m\n\u001b[1;32m 26\u001b[0m \n\u001b[1;32m 27\u001b[0m \u001b[38;5;124;03mThis function performs source-to-source translation of a given object from the source framework\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;124;03mReturns:\u001b[39;00m\n\u001b[1;32m 40\u001b[0m \u001b[38;5;124;03m The translated object.\"\"\"\u001b[39;00m\n\u001b[1;32m 42\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m_compiler\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m source_to_source \u001b[38;5;28;01mas\u001b[39;00m _source_to_source\n\u001b[0;32m---> 44\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_source_to_source\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 45\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mobject\u001b[39;49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mobject\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 46\u001b[0m \u001b[43m \u001b[49m\u001b[43msource\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msource\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 47\u001b[0m \u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtarget\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 48\u001b[0m \u001b[43m \u001b[49m\u001b[43mprofiling\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprofiling\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32mVLL.pyx:15\u001b[0m, in \u001b[0;36mVLL.source_to_source\u001b[0;34m()\u001b[0m\n", | ||
"\u001b[0;31mIvyException\u001b[0m: Unable to find an api key in the IVY_KEY env var, or ivy-key.pem file." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"tf_rgb_to_grayscale = ivy.source_to_source(kornia.color.rgb_to_grayscale, source=\"torch\", target=\"tensorflow\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"torch_input = torch.rand(5, 3, 4, 4)\n", | ||
"tf_input = tf.convert_to_tensor(torch_input.numpy())\n", | ||
"\n", | ||
"torch_output = kornia.color.rgb_to_grayscale(torch_input)\n", | ||
"tf_output = tf_rgb_to_grayscale(tf_input)\n", | ||
"\n", | ||
"assert np.allclose(torch_output.numpy(), tf_output.numpy(), atol=1e-3)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash | ||
|
||
if [ $2 == true ]; then | ||
export VERSION=main | ||
export VERSION=nightly | ||
fi | ||
|
||
cd ivy | ||
|