Tensor.fromJson constructor
Tensor.fromJson(
- Object? j
Implementation
factory Tensor.fromJson(Object? j) {
final json = j as Map<String, Object?>;
return Tensor(
dtype: switch (json['dtype']) {
null => Tensor_DataType.$default,
Object $1 => Tensor_DataType.fromJson($1),
},
shape: switch (json['shape']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeInt64(i)],
_ => throw const FormatException('"shape" is not a list'),
},
boolVal: switch (json['boolVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeBool(i)],
_ => throw const FormatException('"boolVal" is not a list'),
},
stringVal: switch (json['stringVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeString(i)],
_ => throw const FormatException('"stringVal" is not a list'),
},
bytesVal: switch (json['bytesVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeBytes(i)],
_ => throw const FormatException('"bytesVal" is not a list'),
},
floatVal: switch (json['floatVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeDouble(i)],
_ => throw const FormatException('"floatVal" is not a list'),
},
doubleVal: switch (json['doubleVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeDouble(i)],
_ => throw const FormatException('"doubleVal" is not a list'),
},
intVal: switch (json['intVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeInt(i)],
_ => throw const FormatException('"intVal" is not a list'),
},
int64Val: switch (json['int64Val']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeInt64(i)],
_ => throw const FormatException('"int64Val" is not a list'),
},
uintVal: switch (json['uintVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeInt(i)],
_ => throw const FormatException('"uintVal" is not a list'),
},
uint64Val: switch (json['uint64Val']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeUint64(i)],
_ => throw const FormatException('"uint64Val" is not a list'),
},
listVal: switch (json['listVal']) {
null => [],
List<Object?> $1 => [for (final i in $1) Tensor.fromJson(i)],
_ => throw const FormatException('"listVal" is not a list'),
},
structVal: switch (json['structVal']) {
null => {},
Map<String, Object?> $1 => {
for (final e in $1.entries)
decodeString(e.key): Tensor.fromJson(e.value),
},
_ => throw const FormatException('"structVal" is not an object'),
},
tensorVal: switch (json['tensorVal']) {
null => Uint8List(0),
Object $1 => decodeBytes($1),
},
);
}