mirror of
https://github.com/nod-ai/SHARK-Studio.git
synced 2026-01-10 06:17:55 -05:00
Install torch version required by torch-mlir when setting up importer venv. (#486)
This commit is contained in:
@@ -105,8 +105,6 @@ else
|
||||
echo "Not installing a backend, please make sure to add your backend to PYTHONPATH"
|
||||
fi
|
||||
|
||||
$PYTHON -m pip install -e . -f https://llvm.github.io/torch-mlir/package-index/ -f ${RUNTIME} -f https://download.pytorch.org/whl/nightly/torch/
|
||||
|
||||
if [[ ! -z "${IMPORTER}" ]]; then
|
||||
echo "${Yellow}Installing importer tools.."
|
||||
if [[ $(uname -s) = 'Linux' ]]; then
|
||||
@@ -119,6 +117,9 @@ if [[ ! -z "${IMPORTER}" ]]; then
|
||||
$PYTHON -m pip install --no-warn-conflicts --upgrade -r "$TD/requirements-importer-macos.txt" -f ${RUNTIME} --extra-index-url https://download.pytorch.org/whl/nightly/cpu
|
||||
fi
|
||||
fi
|
||||
|
||||
$PYTHON -m pip install --no-warn-conflicts -e . -f https://llvm.github.io/torch-mlir/package-index/ -f ${RUNTIME} -f https://download.pytorch.org/whl/nightly/torch/
|
||||
|
||||
if [[ $(uname -s) = 'Linux' && ! -z "${BENCHMARK}" ]]; then
|
||||
$PYTHON -m pip uninstall -y torch torchvision
|
||||
$PYTHON -m pip install --pre torch torchvision --extra-index-url https://download.pytorch.org/whl/nightly/cu116
|
||||
|
||||
@@ -53,7 +53,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def forward(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -73,7 +73,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -61,7 +61,7 @@ class BertModule(tf.Module):
|
||||
), # input2: segment_ids
|
||||
tf.TensorSpec([BATCH_SIZE], tf.int32), # input3: labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, input_word_ids, input_mask, segment_ids, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -58,7 +58,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -51,7 +51,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -58,7 +58,7 @@ class BertModule(tf.Module):
|
||||
), # input2: segment_ids
|
||||
tf.TensorSpec([BATCH_SIZE], tf.int32), # input3: labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, input_word_ids, input_mask, segment_ids, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -54,7 +54,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -47,7 +47,7 @@ class BertModule(tf.Module):
|
||||
bert_input, # inputs
|
||||
tf.TensorSpec(shape=[BATCH_SIZE], dtype=tf.int32), # labels
|
||||
],
|
||||
jit_compile=True
|
||||
jit_compile=True,
|
||||
)
|
||||
def learn(self, inputs, labels):
|
||||
with tf.GradientTape() as tape:
|
||||
|
||||
@@ -191,7 +191,10 @@ class ResNetModule(tf.Module):
|
||||
self.m = tf_model
|
||||
self.m.predict = lambda x: self.m.call(x, training=False)
|
||||
|
||||
@tf.function(input_signature=[tf.TensorSpec(INPUT_SHAPE, tf.float32)], jit_compile=True)
|
||||
@tf.function(
|
||||
input_signature=[tf.TensorSpec(INPUT_SHAPE, tf.float32)],
|
||||
jit_compile=True,
|
||||
)
|
||||
def forward(self, inputs):
|
||||
return self.m.predict(inputs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user