Skip to content

Commit

Permalink
Get State from real serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuslepukhin committed Jan 13, 2020
1 parent 498f266 commit fc6b0aa
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions onnxruntime/test/featurizers_ops/datetimetransformer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gtest/gtest.h"
#include "test/providers/provider_test_utils.h"

#include "Archive.h"
#include "Featurizers/DateTimeFeaturizer.h"

namespace dft = Microsoft::Featurizer::Featurizers;
Expand All @@ -13,12 +14,21 @@ using SysClock = std::chrono::system_clock;
namespace onnxruntime {
namespace test {

std::vector<uint8_t> GetStream () {
dft::DateTimeTransformer dt("", "");
Microsoft::Featurizer::Archive ar;
dt.save(ar);
return ar.commit();
}

TEST(FeaturizersTests, DateTimeTransformer_past_1976_nov_17_12_27_04) {
const time_t date = 217081624;
OpTester test("DateTimeTransformer", 1, onnxruntime::kMSFeaturizersDomain);

// Add state input
test.AddInput<uint8_t>("State", {8}, {1, 0, 0, 0, 0, 0, 0, 0});
auto stream = GetStream();
auto dim = static_cast<int64_t>(stream.size());
test.AddInput<uint8_t>("State", {dim}, stream);

// We are adding a scalar Tensor in this instance
test.AddInput<int64_t>("Date", {1}, {date});
Expand Down Expand Up @@ -81,7 +91,9 @@ TEST(FeaturizersTests, DateTimeTransformer_past_1976_nov_17_12_27_05) {
OpTester test("DateTimeTransformer", 1, onnxruntime::kMSFeaturizersDomain);

// Add state input
test.AddInput<uint8_t>("State", {8}, {1, 0, 0, 0, 0, 0, 0, 0});
auto stream = GetStream();
auto dim = static_cast<int64_t>(stream.size());
test.AddInput<uint8_t>("State", {dim}, stream);

// We are adding a scalar Tensor in this instance
test.AddInput<int64_t>("Date", {1}, {date});
Expand Down Expand Up @@ -145,7 +157,10 @@ TEST(FeaturizersTests, DateTimeTransformer_past_1976_nov_17__12_27_05_and_past_1
OpTester test("DateTimeTransformer", 1, onnxruntime::kMSFeaturizersDomain);

// Add state input
test.AddInput<uint8_t>("State", {8}, {1, 0, 0, 0, 0, 0, 0, 0});
auto stream = GetStream();
auto dim = static_cast<int64_t>(stream.size());
test.AddInput<uint8_t>("State", {dim}, stream);


// We are adding a scalar Tensor in this instance
test.AddInput<int64_t>("Date", {2}, {date1, date2});
Expand Down Expand Up @@ -233,7 +248,9 @@ TEST(FeaturizersTests, DateTimeTransformer_future_2025_june_30) {
OpTester test("DateTimeTransformer", 1, onnxruntime::kMSFeaturizersDomain);

// Add state input
test.AddInput<uint8_t>("State", {8}, {1, 0, 0, 0, 0, 0, 0, 0});
auto stream = GetStream();
auto dim = static_cast<int64_t>(stream.size());
test.AddInput<uint8_t>("State", {dim}, stream);

// We are adding a scalar Tensor in this instance
test.AddInput<int64_t>("Date", {1}, {date});
Expand Down

0 comments on commit fc6b0aa

Please sign in to comment.