lib/torch.rb in torch-rb-0.2.1 vs lib/torch.rb in torch-rb-0.2.2

- old
+ new

@@ -464,10 +464,16 @@ IValue.from_dict(dict) when true, false IValue.from_bool(obj) when nil IValue.new + when Array + if obj.all? { |v| v.is_a?(Tensor) } + IValue.from_list(obj.map { |v| IValue.from_tensor(v) }) + else + raise Error, "Unknown list type" + end else raise Error, "Unknown type: #{obj.class.name}" end end @@ -488,10 +494,12 @@ dict = {} ivalue.to_generic_dict.each do |k, v| dict[to_ruby(k)] = to_ruby(v) end dict + elsif ivalue.list? + ivalue.to_list.map { |v| to_ruby(v) } else type = if ivalue.capsule? "Capsule" elsif ivalue.custom_class? @@ -508,11 +516,9 @@ "DoubleList" elsif ivalue.bool_list? "BoolList" elsif ivalue.tensor_list? "TensorList" - elsif ivalue.list? - "List" elsif ivalue.object? "Object" elsif ivalue.module? "Module" elsif ivalue.py_object?