Skip to content

Commit

Permalink
java instrumentation test with MV2 (#2029)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2029

A simple test to validate the E2E workflow for Java library (load jni, load module, execute)

Reviewed By: mcr229

Differential Revision: D53953813

fbshipit-source-id: 17f401da0b274eeaf66af72bd90bcb71139b1d73
  • Loading branch information
kirklandsign authored and facebook-github-bot committed Feb 23, 2024
1 parent 1186129 commit ca6995b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"llama2": ("llama2", "Llama2Model"),
"mobilebert": ("mobilebert", "MobileBertModelExample"),
"mv2": ("mobilenet_v2", "MV2Model"),
"mv2_untrained": ("mobilenet_v2", "MV2UntrainedModel"),
"mv3": ("mobilenet_v3", "MV3Model"),
"vit": ("torchvision_vit", "TorchVisionViTModel"),
"w2l": ("wav2letter", "Wav2LetterModel"),
Expand Down
3 changes: 2 additions & 1 deletion examples/models/mobilenet_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from .model import MV2Model
from .model import MV2Model, MV2UntrainedModel

__all__ = [
MV2Model,
MV2UntrainedModel,
]
14 changes: 14 additions & 0 deletions examples/models/mobilenet_v2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ def get_eager_model(self) -> torch.nn.Module:
def get_example_inputs(self):
tensor_size = (1, 3, 224, 224)
return (torch.randn(tensor_size),)


class MV2UntrainedModel(EagerModelBase):
def __init__(self):
pass

def get_eager_model(self) -> torch.nn.Module:
# pyre-ignore
mv2 = mobilenet_v2()
return mv2

def get_example_inputs(self):
tensor_size = (1, 3, 224, 224)
return (torch.randn(tensor_size),)
3 changes: 2 additions & 1 deletion examples/xnnpack/aot_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
required=False,
help="Generate and save an ETRecord to the given file location",
)
parser.add_argument("-o", "--output_dir", default=".", help="output directory")

args = parser.parse_args()

Expand Down Expand Up @@ -110,4 +111,4 @@

quant_tag = "q8" if args.quantize else "fp32"
model_name = f"{args.model_name}_xnnpack_{quant_tag}"
save_pte_program(exec_prog.buffer, model_name)
save_pte_program(exec_prog.buffer, model_name, args.output_dir)

0 comments on commit ca6995b

Please sign in to comment.