mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Fix error messages; tensor creation method names with type (#26219)
Summary: After offline discussion with dzhulgakov : - In future we will introduce creation of byte signed and byte unsigned dtype tensors, but java has only signed byte - we will have to add some separation for it in method names ( java types and tensor types can not be clearly mapped) => Returning type in method names - fixes in error messages - non-static method Tensor.numel() - Change Tensor toString() to be more consistent with python Update on Sep 16: Type renaming on java side to uint8, int8, int32, float32, int64, float64 ``` public abstract class Tensor { public static final int DTYPE_UINT8 = 1; public static final int DTYPE_INT8 = 2; public static final int DTYPE_INT32 = 3; public static final int DTYPE_FLOAT32 = 4; public static final int DTYPE_INT64 = 5; public static final int DTYPE_FLOAT64 = 6; ``` ``` public static Tensor newUInt8Tensor(long[] shape, byte[] data) public static Tensor newInt8Tensor(long[] shape, byte[] data) public static Tensor newInt32Tensor(long[] shape, int[] data) public static Tensor newFloat32Tensor(long[] shape, float[] data) public static Tensor newInt64Tensor(long[] shape, long[] data) public static Tensor newFloat64Tensor(long[] shape, double[] data) ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/26219 Differential Revision: D17406467 Pulled By: IvanKobzarev fbshipit-source-id: a0d7d44dc8ce8a562da1a18bd873db762975b184
This commit is contained in:
committed by
Facebook Github Bot
parent
448c53747a
commit
b07991f7f5
@ -40,7 +40,7 @@ public final class TensorImageUtils {
|
||||
floatArray[offset_b + i] = (b - NORM_MEAN_B) / NORM_STD_B;
|
||||
}
|
||||
final long shape[] = new long[] {1, 3, height, width};
|
||||
return Tensor.newTensor(shape, floatArray);
|
||||
return Tensor.newFloat32Tensor(shape, floatArray);
|
||||
}
|
||||
|
||||
public static Tensor imageYUV420CenterCropToFloatTensorTorchVisionForm(
|
||||
@ -131,7 +131,7 @@ public final class TensorImageUtils {
|
||||
}
|
||||
}
|
||||
final long shape[] = new long[] {1, 3, tensorHeight, tensorHeight};
|
||||
return Tensor.newTensor(shape, floatArray);
|
||||
return Tensor.newFloat32Tensor(shape, floatArray);
|
||||
}
|
||||
|
||||
private static final int clamp(int c, int min, int max) {
|
||||
|
Reference in New Issue
Block a user