Class Aten

java.lang.Object
smile.torch.Aten

public final class Aten extends Object
Calls any registered ATen operator by its schema name through the dispatcher (smile_aten_call), so models can use ops that have no dedicated binding:
Tensor c = Aten.one("aten::cat", new Tensor[]{a, b}, 1);
Tensor[] topk = Aten.call("aten::topk", x, 6, -1, true, true);
Tensor y = Aten.one("aten::masked_fill.Scalar", x, mask, Double.NEGATIVE_INFINITY);

Arguments follow the operator's schema order (see torch.ops.aten.<name>.<overload>._schema); trailing arguments that are left out take their schema defaults. Accepted Java values: Tensor, null (None), Boolean, Integer/Long (int or Scalar), Double/Float, String, int[]/long[] (int[]), Tensor[] (Tensor[]), Aten.OptionalTensors (Tensor?[]) and ScalarType (a dtype argument). Tensor results, and tensor lists flattened, are returned.

Calls run without autograd. Failures throw IllegalStateException with the native message.

  • Field Details

    • STATS

      public static final ConcurrentHashMap<String,long[]> STATS
      Per-operator {calls, nanoseconds} when run with -Dsmile.aten.stats=true, else null.
  • Method Details

    • isAvailable

      public static boolean isAvailable()
      Returns true if the ATen dispatcher entry points are present in smile_torch.
      Returns:
      true if call(String, Object...) is supported by the loaded native library.
    • call

      public static Tensor[] call(String op, Object... args)
      Calls an operator.
      Parameters:
      op - the operator, "aten::name" or "aten::name.overload".
      args - the arguments in schema order.
      Returns:
      the tensor outputs.
    • one

      public static Tensor one(String op, Object... args)
      Calls an operator that returns one tensor.
      Parameters:
      op - the operator.
      args - the arguments in schema order.
      Returns:
      the first output.