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

[benchmark] Allows benchmark run on aarch64 for PyTorch #1591

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public final boolean runBenchmark(String[] args) {
return true;
} catch (ParseException e) {
Arguments.printHelp(e.getMessage(), options);
} catch (Throwable t) {
} catch (TranslateException | ModelException | IOException | ClassNotFoundException t) {
logger.error("Unexpected error", t);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ai.djl.Device;
import ai.djl.ModelException;
import ai.djl.engine.Engine;
import ai.djl.engine.EngineException;
import ai.djl.inference.Predictor;
import ai.djl.metric.Metrics;
import ai.djl.repository.zoo.ZooModel;
Expand All @@ -37,26 +38,28 @@ public final class Benchmark extends AbstractBenchmark {
* @param args command line arguments
*/
public static void main(String[] args) {
String arch = System.getProperty("os.arch");
if (!"x86_64".equals(arch) && !"amd64".equals(arch)) {
logger.warn("{} is not supported.", arch);
return;
}
List<String> list = Arrays.asList(args);
boolean success;
if (!list.isEmpty() && "ndlist-gen".equals(list.get(0))) {
success = NDListGenerator.generate(Arrays.copyOfRange(args, 1, args.length));
} else {
boolean multithreading = list.contains("-t") || list.contains("--threads");
configEngines(multithreading);
if (multithreading) {
success = new MultithreadedBenchmark().runBenchmark(args);
try {
boolean success;
if (!list.isEmpty() && "ndlist-gen".equals(list.get(0))) {
success = NDListGenerator.generate(Arrays.copyOfRange(args, 1, args.length));
} else {
success = new Benchmark().runBenchmark(args);
boolean multithreading = list.contains("-t") || list.contains("--threads");
configEngines(multithreading);
if (multithreading) {
success = new MultithreadedBenchmark().runBenchmark(args);
} else {
success = new Benchmark().runBenchmark(args);
}
}
}
if (!success) {
System.exit(-1); // NOPMD
if (!success) {
System.exit(-1); // NOPMD
}
} catch (EngineException e) {
String osName = System.getProperty("os.name");
String arch = System.getProperty("os.arch");
logger.warn("Engine is not supported on {}:{}.", osName, arch);
logger.debug("Failed to load engine", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package ai.djl.benchmark;

import ai.djl.Device;
import ai.djl.ndarray.NDList;
import ai.djl.ndarray.NDManager;
import ai.djl.ndarray.types.DataType;
Expand Down Expand Up @@ -56,7 +57,7 @@ static boolean generate(String[] args) {
boolean ones = cmd.hasOption("ones");
Path path = Paths.get(output);

try (NDManager manager = NDManager.newBaseManager()) {
try (NDManager manager = NDManager.newBaseManager(Device.cpu(), "PyTorch")) {
NDList list = new NDList();
for (Pair<DataType, Shape> pair : parseShape(inputShapes)) {
DataType dataType = pair.getKey();
Expand Down